从子类Python导入(Importing from sub class Python)

编程入门 行业动态 更新时间:2024-10-27 13:24:06
子类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)

更多推荐

本文发布于:2023-08-03 06:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1383906.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子类   Python   class   Importing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!