How to check Python class hierarchy?

Assuming I have class X, how can I check which of the base classes / classes and their base class / classes, etc.?

I use Eclipse with PyDev, and for Java, for example, you can type CTRL + T on the class name and see the hierarchy, for example:

  java.lang.Object
    java.lang.Number
        java.lang.Integer

Is this possible for Python?

If this is not possible in Eclipse PyDev, where can I find this information?

+7
source share
4 answers

Press f4 with the class name highlighted to open the hierarchy view.

+8
source
+5
source

In addition, each class carries an __mro__ attribute, which gives all the parent classes from which the given class can 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'>) 
+2
source

Press + o, then press Ctrl + O to show the parent hierarchy

check out this blog http://pydev.blogspot.jp/2015/03/navigating-through-your-code-when-in.html

0
source

All Articles