Fredrik Lundh effbot at
Thu Feb 17 13:20:42 EST 2000

Joshua C. Marshall <jayantha at> 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)
>>> issubclass(A, B)

hope this helps!


More information about the Python-list mailing list