Trying to generate a list of the subclasses of C

Charles Krug cdkrug at aol.com
Thu Jan 19 00:59:00 CET 2006


On 2006-01-16, Alex Martelli <aleax at mail.comcast.net> wrote:
> Charles Krug <cdkrug at aol.com> wrote:
>    ...
>> I'm trying to create a list of all of C's subclasses:
>
> There's a class method for that very purpose:
>
>>>> class C(object): pass
> ... 
>>>> class D(C): pass
> ... 
>>>> class E(C): pass
> ... 
>>>> C.__subclasses__()
> [<class '__main__.D'>, <class '__main__.E'>]
>>>> 
>
>
> Alex

Exactly what I was looking for, thanks.

It stuck in my brain that there was a way to do this, but I couldn't lay
my mouse on it.




More information about the Python-list mailing list