Pickora icon indicating copy to clipboard operation
Pickora copied to clipboard

Lambda doesn't see changes of global variables

Open splitline opened this issue 4 years ago • 0 comments

The globals for lambda is just a clone/snapshot of current context. https://github.com/splitline/Pickora/blob/7e0e8eb2f66408d78553a8af3e2bc85e2f5a36d8/compiler.py#L355-L358

So if any global variables are changed after the lambda definition, the lambda won't see those changes For example:

val = 'before'
f = lambda:val
val = 'after'
print(f())  # before

I am not sure if there are any way to fix this 🤔

splitline avatar Jul 15 '21 10:07 splitline