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?
you need see inspect. For example
inspect.getmembers(object, inspect.ismethod)
it returns only method.
You can filter dir result
[method for method in dir(obj) if callable(getattr(obj, method))]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With