0

If I have a class, how can I get a list of functions, methods and other callables defined in this class (so nothing inherited from object, etc.)?

I have seen this question, but it requires me to first get a complete list of attributes and then call this method for each callable and compare classes.

Is there a more simple solution?

rfg
  • 1,217
  • 1
  • 7
  • 19

2 Answers2

1

The special attribute __dict__ contains all members attributes defined in a class. It may not exists for objects where the class defined a __slots__ attribute, but I have never seen a metaclass (the class of class objects) defining it.

You can then use inspect.isfunction to know where an attribute is callable.

Serge Ballesta
  • 121,548
  • 10
  • 94
  • 199
0

As mentioned in the above answer, you can either use dir(yourClass) or you can use use help(yourClass).

Shariq
  • 505
  • 3
  • 14