我如何检查某物是子类还是类。比如说:
class Cat(object):
def __init__(self,run,fast):
"""run is a list of speeds or something. But it can be from dogs or cats. Fast is a single number"""
self.run=run
self.fast=fast
class Dog(Class):
def __init_(self,run, fast):
Cat.__init__(self,run,fast)
self.jumper=[]
def update(self)
for number in self.fast:
if number is CATTYPE:
self.jumper.append(number)
if number is DOGTYPE:
self.jumper.append(number)
基本上我正在尝试,在所有大写的地方,找到一种方法来使声明快速找到它是否是猫类型,然后附加到跳线。我知道这是一个愚蠢的例子,但我想知道当一个是另一个的子类时如何处理这个问题。