所以我有一个类,字符()和子类,npc(字符).它们看起来像这样:
class character():
def __init__(self,name,desc):
self.name = name
self.desc = desc
self.attr = ""
#large list of attributes not defined by parameters
和
class npc(character):
def __init__(self,greetings,topics):
self.greetings = greetings
self.topics = topics
character.__init__(self)
self.pockets = []
#more attributes specific to the npc subclass not defined by parameters
然而,当我从’Npc’中调用’Character’中应该存在(或者我认为)的属性时,比如’name’或’desc’或’attr’,我得到一个“不存在/未定义”的错误.我只是不做继承吗?这里发生了什么?我混淆了属性和参数吗?