News for hackers. Stuff that matters.
Re:Understanding a Python Closure Oddity by geysersam on Monday June 17, 2024 @10:41AM (#40706081)
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!

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).
Re:Understanding a Python Closure Oddity by zbentley on Wednesday June 19, 2024 @10:06AM (#40728438)
er, functools.partial, too late to edit.