Finding a class' superclasses

  • Thread starter Hallvard B Furuseth
  • Start date
H

Hallvard B Furuseth

How do I find a class' immediate superclasses?
That is, given
class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass
I want a function foo where foo(D) or foo(D()) returns (B, C).
(Well, the order of the classes is not important.)
 
M

Michael Hudson

Hallvard B Furuseth said:
How do I find a class' immediate superclasses?
That is, given
class A: pass
class B(A): pass
class C(A): pass
class D(B, C): pass
I want a function foo where foo(D) or foo(D()) returns (B, C).
(Well, the order of the classes is not important.)

D.__bases__?

Cheers,
mwh
 
H

Hallvard B Furuseth

Michael said:
D.__bases__?

Aah. Thanks. And now that I know what to look for, I see it right
where it's supposed to be and where I didn't see it last time in the
Python reference:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top