Given a Python object of any kind, is there an easy way to get the list of all methods that this object has?
Or if this is not possible, is there at least an easy way to check if it has a particular method, other than checking if an error occurs when the method is called?
For many objects, you can use this code, replacing ‘object’ with the object you’re interested in:
I discovered it at diveintopython.net (now archived), that should provide some further details!
If you get an
AttributeError, you can use this instead:getattr()is intolerant of pandas style Python 3.6 abstract virtual sub-classes. This code does the same as above and ignores exceptions.