[Disclaimer: there may be more pythonic ways of doing what I want to do, but I want to know how python\'s scoping works here]
I\'m trying to find a way to make a dec
I found an interesting post provides a different solution by creating functions on the fly. Basically:
def wrapper(func):
cust_globals = func.__globals__.copy()
# Update cust_globals to your liking
# Return a new function
return types.FunctionType(
func.__code__, cust_globals, func.__name__, func.__defaults__, func.__closure__
)
See https://hardenedapple.github.io/stories/computers/python_function_override/