How can I list all subclasses of a Class?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I list all subclasses of a Class?

Luis Antonio Rodriguez
Hi,

Readng the book i didn't find a specific feature to list all subclasses of a class, how do we can do it?
Reply | Threaded
Open this post in threaded view
|

Re: How can I list all subclasses of a Class?

Jiba
Administrator
Hi,

You can use Class.descendants() for listing all subclasses (including subclasses of subclasses, recursively), or Class.subclasses() to obtain only direct subclasses.

NB subclasses returns a generator, you may use list(Class.subclasses()) to turn it into a list.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How can I list all subclasses of a Class?

Luis Antonio Rodriguez
Thank you!!!

:-)