Comment by geysersam
12 days ago
If you want to "close over" the value in the closure then there's a simple trick you can use:
Pass a keyword argument with the default value equal to the value you want to close over.
Voila!
12 days ago
If you want to "close over" the value in the closure then there's a simple trick you can use:
Pass a keyword argument with the default value equal to the value you want to close over.
Voila!
Functions.partial can also supply captures in that way, and is slightly more obvious (and less likely to generate linter complaints if the kwarg is mutable).
er, functools.partial, too late to edit.