How do I access the namespace of another module or function in python?
For example, let's say I have access to a function f that has been passed, and I want get a variable it has access to.
class function_creator():
def __init__(self, start_num):
self.number = start_num
def getfunc(self):
def nestedfunc():
print(f'The number you were trying to find was {self.number}')
self.number += 1
return nestedfunc
f = function_creator(5).getfunc()
Running f() will print the number, however I cannot find how to access it directly.