-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The globals for lambda is just a clone/snapshot of current context.
Lines 355 to 358 in 7e0e8eb
| func_globals = ast.Dict(keys=[], values=[]) | |
| for name in code_args[8]: # co_names | |
| func_globals.keys.append(ast.Constant(value=name)) | |
| func_globals.values.append(ast.Name(id=name)) |
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()) # beforeI am not sure if there are any way to fix this 🤔
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working