小编Ale*_*ell的帖子

Python中的类继承

我是python的新手,并试图获取对象类继承的类的列表.我正在尝试使用该bases属性执行此操作,但我没有取得任何成功.有人可以帮帮我吗?

def foo(C):
     print(list(C.__bases__))

class Thing(object):
    def f(self):
        print("Yo")

class Shape(Thing):
    def l(self):
        print("ain't no thang")

class Circle(Shape):
    def n(self):
        print("ain't no shape")

test = Circle()
foo(test)
Run Code Online (Sandbox Code Playgroud)

python inheritance attributes

5
推荐指数
1
解决办法
932
查看次数

标签 统计

attributes ×1

inheritance ×1

python ×1