从子类Python导入(Importing from sub class Python)
这是我的名为Game_Factors python文件:
from Fesnoria_Game_Setup import Game_Setup class Game_Events(Game_Setup): def __init__(self): super(Game_Events, self).game_setup(self.MAP_FILENAME, self.GS)我正在导入包含子类Setup Game_Setup类。
在子类Setup我有两个变量,一个名为self.MAP_FILENAME ,另一个名为self.GS ,我在导入Game_Setup类时将其用作参数。
但是当使用self.MAP_FILENAME和self.GS作为参数导入Game_Setup类时,我得到错误代码:
AttributeError: 'Game_Factors' object has no attribute 'MAP_FILENAME'我有什么想法可以解决这个问题?
Game_Setup:
class Game_Setup(Setup): def __init__(self) super(Game_Setup, self).__init__()Here is my python file called Game_Factors:
from Fesnoria_Game_Setup import Game_Setup class Game_Events(Game_Setup): def __init__(self): super(Game_Events, self).game_setup(self.MAP_FILENAME, self.GS)I am importing the class Game_Setup which contains the sub class Setup.
In the sub class Setup I have two variables, one called self.MAP_FILENAME and the other called self.GS, which I use as arguments when importing the Game_Setup class.
But when importing the Game_Setup class with the self.MAP_FILENAME and self.GS as arguments I get the error code:
AttributeError: 'Game_Factors' object has no attribute 'MAP_FILENAME'Any ideas how I can fix this?
Game_Setup:
class Game_Setup(Setup): def __init__(self) super(Game_Setup, self).__init__()最满意答案
尝试这个:
def __init__(self): super(Game_Events, self).__init__() self.game_setup(self.MAP_FILENAME, self.GS)Try this:
def __init__(self): super(Game_Events, self).__init__() self.game_setup(self.MAP_FILENAME, self.GS)更多推荐
发布评论