class Cat(object):
def __init__(self,run,fast):
self.run=run
self.fast=fast
def skip(self,to,store):
return 'Cat'
class Dog(Cat):
def __init_(self,run, fast,tongue):
Cat.__init__(self,run,fast)
self.tongue=tongue
def skip(self,to,store,happier):
return 'Doggy'
class Parent(object):
def __init__(self,velocity):
self.velocity=velocity
"""
velocity is a list of speeds or something. But it can
be from dogs or cats. Fast is a single number
"""
class Owner(Parent):
def __init__(self,smile):
Parent.__init__(self,velocity)
self.smile=smile
self.jumper=[]
def update(self):
# velocity is a list of instances of cats and dog
for number in self.velocity:
if isinstance(number,Dog):
number.skip(to,store,happier)
self.jumper.append(number)
if isinstance(number,Cat):
number.skip(to,store)
self.jumper.append(number)
这个问题一直存在,我说如果if语句在if实例更新方法中,它不断给我一个类型错误,它说我只需要跳过而不是三个参数。然而,我知道,因为它正在进行,我必须拥有的是狗,这需要三个论点。为什么这种类型的错误不断出现?愚蠢的例子,但类型错误?
等待,你在输入什么内容? – Greg
运行可能是这样的: – user2175034
你可能会得到一个错误,因为所有者没有属性运行也开始 – Greg