Superclasses

Tres Seaver tseaver at starbase.neosoft.com
Thu Feb 17 19:15:01 CET 2000


In article <Pine.GSO.4.21.0002171227410.16470-100000 at sirius.ccs.neu.edu>,
Joshua C. Marshall <jayantha at ccs.neu.edu> wrote:
>Given a class object, is there a way to get at its superclass object?  I'm
>looking for something like:
>
>  class A: pass
>
>  class B(A): pass
>
>  B.__superclass__ == A  # where this is true
>
>Please CC jayantha at ccs.neu.edu
>

Nowhere, but try:

  >>> B.__bases__
  (<class __main__.A at 7f57d0>,)

Note that Python classes can have multiple superclasses.

  >>> class C: pass
  ...
  >>> class D( B, C ): pass
  ...
  >>> D.__bases__
  (<class __main__.B at 7f5630>, <class __main__.C at 7f5bf0>)

Genealogical'ly,

Tres.
-- 
---------------------------------------------------------------
Tres Seaver           tseaver at palladion.com       713-523-6582
Palladion Software    http://www.palladion.com



More information about the Python-list mailing list