How to examine the inheritance of a class?

James Mills prologic at shortcircuit.net.au
Thu Oct 23 21:59:46 EDT 2008


On Fri, Oct 24, 2008 at 11:36 AM, John Ladasky <ladasky at my-deja.com> wrote:
> etc.  The list of subclasses is not fully defined.  It is supposed to
> be extensible by the user.

Developer. NOT User.

Consider:

$ python
Python 2.5.2 (r252:60911, Oct 13 2008, 15:09:03)
[GCC 4.2.4 (CRUX)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object): pass
...
>>> class Spam(Foo): pass
...
>>> Spam.__class__.__bases__
(<type 'object'>,)
>>> Spam.__class__
<type 'type'>
>>> Spam.__bases__
(<class '__main__.Foo'>,)
>>> spam = Spam()
>>> spam.__class__
<class '__main__.Spam'>
>>> spam.__class__.__bases__
(<class '__main__.Foo'>,)
>>>

cheers
James

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list