[Chicago] Walking a class tree using dir

Michael Steder steder at gmail.com
Thu Aug 18 23:21:00 CEST 2011


You could do it with `dir` but that seems unnecessary.  Have you tried using cls.mro()?

import idiot
for base in idiot.Idiot.mro():
    print "%s: %s"%(base.__name__, base.__dict__.keys()) 

~Mike

On Aug 16, 2011, at 2:07 PM, Joshua Herman wrote:

> Is there any utility that will walk through the class tree? What I
> mean as follows
> 
> Given an input of a class. Lets call it Idiot
> Idiot has three subclasses. Dunce , Troll and __init__
> Dunce and Troll both have associated methods also.
> 
> 
> The output would be such
> 
> idiot --> Dunce, Troll
> Dunce --> Talk
> Troll -> Make fun of python listserv
> 
> Is there a python program that would walk it for me and generate a
> graph or a text output of all the dir's
> 
> 
> 
> ---Profile:---
> http://www.google.com/profiles/zitterbewegung
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago



More information about the Chicago mailing list