Problem with OrderedDict - progress report

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jun 1 19:10:52 EDT 2018


Chris Angelico wrote:
> if you 'break' immediately after a mutation, that isn't
> continuing to iterate. Even though you're inside the loop, there's no
> further action taken to process the loop, and no problem.

Yes, but you're also not calling next() again, so no
exception would be triggered.

My point is that I don't see a justification for treating
the last next() call (the one that notices you've reached
the end and raises StopIteration) any differently from
the others. It seems like either a bug or a misfeature
to me.

-- 
Greg



More information about the Python-list mailing list