I have a decorator which inits a global dict which I want to modify within the decorated function. I have tried an implementation something like below:
def decorator():
def inner_function(func):
global_dict = {}
print("Inner function")
ret = func()
return ret
return inner_function
@decorator()
def test_function():
global global_dict
global_dict["something"] = "something"
print("Test function")
return True
This gives me an error: name 'global_dict' is not defined
and I am not really sure why. How would I go about doing this?