2

I want to get every methods of an object. I know about the function dir but it returns all(method, attr, meta_data).

I tried this:

[x for x in dir(obj) if "_" not in x]

but it does not work correctly.

How can I do it?

Filippo Vitale
  • 7,155
  • 3
  • 57
  • 61
Tany
  • 373
  • 1
  • 3
  • 16
  • possible duplicate of [Finding what methods an object has](http://stackoverflow.com/questions/34439/finding-what-methods-an-object-has) – Rene Korss Jul 15 '15 at 07:10

2 Answers2

4

You can filter dir result

[method for method in dir(obj) if callable(getattr(obj, method))]
itzMEonTV
  • 18,806
  • 3
  • 37
  • 48
3

you need see inspect. For example

inspect.getmembers(object, inspect.ismethod)

it returns only method.

Anna
  • 43
  • 5