How can I modify the local namespace of a function in python? I know that locals() returns the local namespace of the function when called inside it, but I want to do somet
I think you could solve the problem tackling it from a completely different point.
Functions are object, with their dictionaries; therefore, you can add g to f, and use it: