Getting a list of all classes derived from a base class

Alex Martelli aleaxit at yahoo.com
Mon Apr 3 02:48:04 EDT 2006


Vijairaj  R <Vijairaj.R at gmail.com> wrote:
   ...
> class Test:

do not use old-style classes: they exist ONLY for backwards
compatibility.

Make you class Test new-style:

class Test(object):
   ...


and you can call Test.__subclasses__() to get a list of all extant
subclassed of Test at any time.


Alex



More information about the Python-list mailing list