masklinn í dag viðrar vel til loftárása | Code :
def superTree(cls, level=0): print "%s%s"%(" "*level, cls.__name__) for c in cls.__bases__: superTree(c, level+1)
|
Demo:
Code :
>>> class Foo(object): pass >>> class Bar(list): pass >>> class Baz(object): pass >>> class Buzz(Foo, Bar, Baz): pass >>> class Foobar(Buzz, dict): pass >>> class Bizz(object): pass >>> class Foobar(Buzz, Bizz): pass >>> superTree(Foobar) Foobar Buzz Foo object Bar list object Baz object Bizz object
|
---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
|