Superclasses
Fredrik Lundh
effbot at telia.com
Thu Feb 17 13:20:42 EST 2000
Joshua C. Marshall <jayantha at ccs.neu.edu> wrote:
> Given a class object, is there a way to get at its superclass object?
the thing you're looking for is "__bases__"
(it's called "base class" in python, and you can
have more than one)
>>> class A:
... pass
...
>>> class B(A):
... pass
...
>>> B.__bases__
(<class __main__.A at 795410>,)
to check if a class is a subclass to any other
class, use "issubclass":
>>> issubclass(B, A)
1
>>> issubclass(A, B)
0
hope this helps!
</F>
More information about the Python-list
mailing list