Introspection: determining parent classes?

Mark McEahern marklists at mceahern.com
Fri Jun 28 16:20:47 EDT 2002


isinstance will do the trick.

class A:pass
class B(A):pass
class C(B):pass

c = C()
print isinstance(c, A)
1

If you need to traverse the bases:

c.__class__.__bases__

// m
-






More information about the Python-list mailing list