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,331
  • 1
  • 8
  • 24

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
  • 143,923
  • 11
  • 122
  • 252
-1

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

Shariq
  • 513
  • 4
  • 14