Get the list of a class's variables & methods in Python

后端 未结 4 1856
后悔当初
后悔当初 2021-01-02 18:06

If I have the following class, what\'s the best way of getting the exact list of variables and methods, excluding those from the superclass?

class F         


        
4条回答
  •  难免孤独
    2021-01-02 18:24

    In your example, a is an instance, its __dict__ will include all variables set in its __init__ function. To get all class variables, use a.__class__.__dict__

提交回复
热议问题