class Method(object):
def __call__(self):
#how could I get the App instance here?
return True
class App(object):
def __init__(self):
self.g = Method()
As you can see, the above code can explain my question.
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.
You’d have to store a pointer back to the App object in the Method:
If you have an absolute need to avoid passing the
selfpointer in App, you’ll need to inspect the stack to retrieve it instead.The following is discouraged and only works when you instantiate
Methodobjects in a method ofApp: