News for hackers. Stuff that matters.
Re:Understanding a Python Closure Oddity by gpderetta on Monday June 17, 2024 @11:31AM (#40706634)
Typical workaround:

  def loop():
     for number in range(10):
        def closure(number=number):
            return number
        yield closure
Many languages have surprising behaviour when closing over iteration variables.

There are no comments on this comment yet.