2 ms·
> You're talking about something different. No I’m not. Exercise for the reader to figure out why. The key thing here is that you want a mutable variable for e
by klodolph 6y ago
> You're talking about something different.
No I’m not. Exercise for the reader to figure out why. The key thing here is that you want a mutable variable for each closure, but not shared between loop iterations.
- quietbritishjim 6y ago[Edit: deleted my original reply here. I had ended in "Are you sure you didn't misread the original comment?"] Ah ha! I misread your comment! This was the bit that confused me: > They're also an escape hatch, I read this as > There's also an escape hatch, So I thought you were saying that the code in your comment was a solution to the problem posted by the original comment. This is why I found your comment so bewildering! I now see that what you were saying that this gotcha (Python evaluates function default arguments, once, at the point of definition) also has a use. So, I have to say sorry about that. But I also can't help saying your comment could've been phrased a bit less confusingly.