On Fri, Jun 1, 2018 at 4:56 PM Gregory Ewing <greg.ew...@canterbury.ac.nz>
wrote:

> Chris Angelico wrote:
> > It is an error to mutate the dictionary *and then continue to iterate
> over it*.
>
> But if you're processing the last key, and you add one so
> that it's no longer the last key, what should happen?
>
> My feeling is that this should be an error, because it's
> not clear whether iteration should stop at that point
> or not.
>
> --
> Greg
> --
> https://mail.python.org/mailman/listinfo/python-list
>

​Regardless how CPython works, it's prohibited, and behavior is
**undefined**.​
There are no "what should happen".

Python interpreters may or may not raise error.  And any error
(RuntimeError,
MemoryError, interpreter freeze) may happen.

Python programmer shouldn't rely on the behavior.

​Regards,​

-- 
INADA Naoki  <songofaca...@gmail.com>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to