Assume a nested function in python, where outer denotes the outer function and inner denotes the inner function. The outer function provides parametrization of the inner function and returns an instance of this parametrized function.
I want to obtain the name of the outer function, given an instance of the inner function which is returned by the outer function. The code is as follows:
def outer(a):
def inner(x):
return x*a
return inner
p = outer(3)
print p # prints inner
print p(3) # prints 9
How can I print the name of the outer function, ie outer, given only p?
Thanks!
print ponly prints 'inner' because 'outer' returns a function that happens to be 'inner'