-
-
Save chkoar/7c2eab0b760a3651e52ddc420d553382 to your computer and use it in GitHub Desktop.
Get the methods of an object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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