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
8,1633 gold badges65 silver badges66 bronze badges
-
possible duplicate of Finding what methods an object hasRene Korss– Rene Korss2015年07月15日 07:10:08 +00:00Commented Jul 15, 2015 at 7:10
2 Answers 2
you need see inspect. For example
inspect.getmembers(object, inspect.ismethod)
it returns only method.
Sign up to request clarification or add additional context in comments.
Comments
You can filter dir result
[method for method in dir(obj) if callable(getattr(obj, method))]
answered Jul 15, 2015 at 7:01
itzMEonTV
20.4k4 gold badges44 silver badges53 bronze badges
Comments
lang-py