how to access to the direct subclasses of classes?

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

how to access to the direct subclasses of classes?

ghazouani
Hi,
I am trying to use Owlready2 to get subclasses (or descendants) of a class.

The class.descendants() allows to get all the direct classes and the subclasses of these classes.  
I need only to get the direct classes without the subclasses. For exemple, if I have a class A and B, C are subclasses of A, and B1 subclass of B, C2 subclass of C :

A.descendants() get [B, C, B1, C1]. What  I need is [B, C] only.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: how to access to the direct subclasses of classes?

Jiba
Administrator
Hi,

You can use Class.subclasses().

Jiba