Getting the super class via the super() function
Michael Hudson
mwh at python.net
Fri Nov 21 12:04:21 EST 2003
Fernando Rodriguez <frr at easyjob.net> writes:
> Hi,
>
> I need to traverse the methods defined in a class and its superclasses. This
> is the code I'm using:
[...]
> What am I doing wrong? I'm afraid that super isn't returning a
> reference to the superclass... :-?
That's right, it's not. Python supports multiple inheritance -- what
is *the* superclass?
For new-style classes you're probably best off just looking through
cls.__mro__.
Cheers,
mwh
--
That's why the smartest companies use Common Lisp, but lie about it
so all their competitors think Lisp is slow and C++ is fast. (This
rumor has, however, gotten a little out of hand. :)
-- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list