On 6/12/2015 11:00 AM, Fabien wrote:
is it a bad practice
to interactively modify the list you are iterating over?

One needs care. Appending to the end of the list is OK, unless you append a billion items or so ;-) Appending to the end of a queue while *removing* items from the front of the queue, where the queue resizes itself at the front as needed, is standard for breadth-first search. A deque.Deque can be used for this. Depth-first search appends to and deletes from the end (or top) of a stack, but this is NOT forward-iteration as implemented by Python iterators.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to