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 语句,它不断给我一个类型错误,它说我只需要为 skip 而不是三个参数。但是我知道因为它在块中,所以我必须拥有的实例是 dog,它需要三个参数。为什么会不断出现这种类型的错误?