Re:Understanding a Python Closure Oddity
by zbentley on Tuesday June 18, 2024 @02:05PM
(#40720501)
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).
Pass a keyword argument with the default value equal to the value you want to close over.
Voila!