Introspection: determining parent classes?

Mark McEahern marklists at mceahern.com
Fri Jun 28 22:20:47 CEST 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