zip as iterator and bad/good practices
Terry Reedy
tjreedy at udel.edu
Fri Jun 12 19:27:44 EDT 2015
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
More information about the Python-list
mailing list