You can do this via inspect
. The contents of the get()
function can be:
import inspect
myCaller = inspect.currentframe().f_back.f_locals['self']
After that, you have the caller's instance refered to by myCaller
.
Disclaimer: this is not a good practice, because it ruins the whole point of encapsulation.