class MyClass:
def myMethod(self):
pass
myInstance = MyClass()
methodReference = myInstance.myMethod
Now can you get a reference to myInstance if you now only have access to methodReference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using Python 3:
Otherwise:
and by a similar token, for the class:
For this kind of code discovery you should install iPython and use tab, for instance, in your case myReference.+TAB would give:
Hence, you don’t need to worry about remembering things so much – you know that the method is probably provided by the function object and from the suggestions that iPython gives it’s usually obvious what method/attribute you’re looking for.