Jun-05-2022, 11:02 PM
I'm confused about defining the parent of a function as the frame in which the function is defined as it pertains to a HOF that defines a function and then drops out of scope.
def foo(x): print(f'foo x: {x}') return x def bar(f): print(f'bar f: {f}') def bat(y): print(f'bat f(y): {f(y)}') return y return bat new_func = bar(foo) # f1 bar parent = global # f = foo # return bat # Doesn't f1 cease to exist here? Out of scope new_func(5) # f2 new_func parent = f1 # y = 5 # return y # If f1 is out of scope, how can the parent of f2 be f1?