Is there a way to declare that a function should use the scope of the caller?
问题 is there a feautre similar to C macros which lets you reuse code in an inline manner, without creating a seperate scope for that piece of code? for example: a=3 def foo(): a=4 foo() print a will print 3, however i want it to print 4. i am aware of solutions involving objects like classes or a global dict, however i'm looking for a more primitive solution (like a function decorator for example) that would simply let me make changes inside the scope of the caller instead. thank you very much