我的代码如下,其中sdl2ext.Entity
是第三方类。
class Grid(sdl2ext.Entity):
def __init__(self, world):
self.w = 3
self.h = 3
super(Grid,self).__init__()
def dump(self):
print(self.w)
def run():
world = sdl2ext.World()
g = Grid(world)
g.dump()
if __name__ == "__main__":
run()
我得到的具体错误是行print(self.w)
:
AttributeError: object ''Grid'' has no attribute ''w''
这是否与初始化基础对象sdl2ext.Entity
?