Skip to content

Instantly share code, notes, and snippets.

@chkoar
Created September 10, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chkoar/7c2eab0b760a3651e52ddc420d553382 to your computer and use it in GitHub Desktop.
Save chkoar/7c2eab0b760a3651e52ddc420d553382 to your computer and use it in GitHub Desktop.
Get the methods of an object
import inspect
class MySuperObject(object):
def __init__(self):
self.a = 1
self.b = 2
def compute(self):
print("Foo")
def get_object_methods(obj):
return [method for method in dir(obj) if inspect.ismethod(getattr(obj, method))]
mso = MySuperObject()
methods = get_object_methods(mso)
print(methods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment