-4
嘿,伙计们需要知道的如何在从类B中的ClassA的启动方法如何从python中的不同类启动或调用函数?
有
classA(object):
def __init__(self):
#this is where the ClassB method'' def multiplyPeople() ''should be called or started.
classB(object):
def multiplyPeople(self):
它给了一个错误
TypeError: unbound method multiplyPeople() must be called
with classB instance as first argument (got nothing instead)
知道这是一些基本的东西,但我试图弄清楚究竟应该做什么以及我迷失方向。
我把它称为是
classA(object):
def__init__(self):
self.PeopleVariable=classB.multiplyPeople()
你是怎样尝试调用呢? –
你能展示你的更多代码吗?使用您提供的代码,它与您提供的错误消息无关。此外,您提供的代码功能不完整,因为它有语法错误。请发布您的实际代码 – idjaw
您需要先创建一个“B”实例,然后才能调用此类的方法(除非您使用的是静态或类方法) – MSeifert