Re: Traversing Inheritance Model

2006-06-26 Thread Ziga Seilnacht
[EMAIL PROTECTED] wrote:
> What's the best way to traverse the web of inheritance? I want to take
> a class and traverse its bases and then the bases' bases etc
> looking for a particular class. What first came to mind was nested for
> loops. However, I want to know if there's some pre-existing method for
> doing this or if this isn't even possible (might send me in circles
> perhaps?).Thanks all.

The __mro__ descriptor does what you want. Example:

>>> class A(object):
... pass
...
>>> class B(object):
... pass
...
>>> class C(A, B):
... pass
...
>>> C.__mro__
(, , ,
)

See:
http://www.python.org/download/releases/2.2.3/descrintro/
and
http://www.python.org/download/releases/2.3/mro/
for details.

Ziga

-- 
http://mail.python.org/mailman/listinfo/python-list


Traversing Inheritance Model

2006-06-26 Thread digitalorganics
What's the best way to traverse the web of inheritance? I want to take
a class and traverse its bases and then the bases' bases etc
looking for a particular class. What first came to mind was nested for
loops. However, I want to know if there's some pre-existing method for
doing this or if this isn't even possible (might send me in circles
perhaps?).Thanks all.

-- 
http://mail.python.org/mailman/listinfo/python-list