Assuming I have a class X, how do I check which is the base class/classes, and their base class/classes etc?
I'm using Eclipse with PyDev, and for Java for example you could type CTRL + T on a class' name and see the hierarchy, like:
java.lang.Object java.lang.Number java.lang.Integer
Is it possible for Python?
If not possible in Eclipse PyDev, where can I find this information?
Hit f4 with class name highlighted to open hierarchy view.
Try inspect.getclasstree().
Also, every class carries around with it an attribute called __mro__
which gives all the parent classes from which a given class could inherit methods or attributes. Read them from left to right. For example:
assert bool.__mro__ == (<class 'bool'>, <class 'int'>, <class 'object'>)
assert True.__class__.__mro__ == (<class 'bool'>, <class 'int'>, <class 'object'>)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With