I guess, the answer is "no", since someone else asked something similar a while ago, but a lot happens in 7 years..
In some quite non-pythonic experiment I'd like to write a decorator which calls it's wrapped function and react on what's happening inside this function.
Currently a detail bugs me:
def my_decorator(fn):
print(execute_and_get_value(fn, "some_value")
@my_decorator
def foo():
some_value = 23
my_decorator
should run fn()
on module load (that's the part which works) and then somehow get the value of some_value
defined in foo()
. All I want to know if that's technically possible at all.
One approach would be to let foo()
access a member to some global object instead of writing to a local variable and just read that global object afterwards. But that's cheating.
Is that possible or resp. is there a way to prove this impossible?