Re: mutating a deque whilst iterating over it

2021-02-14 Thread duncan smith
On 13/02/2021 19:12, Dan Stromberg wrote: > On Sat, Feb 13, 2021 at 10:25 AM duncan smith > wrote: > >> On 12/02/2021 03:04, Terry Reedy wrote: >>> On 2/11/2021 3:22 PM, duncan smith wrote: >>> It seems that I can mutate a deque while iterating over it if I assign to an index, bu

RE: mutating a deque whilst iterating over it

2021-02-13 Thread Avi Gross via Python-list
PM To: duncan smith Cc: Python List Subject: Re: mutating a deque whilst iterating over it On Sat, Feb 13, 2021 at 10:25 AM duncan smith wrote: > On 12/02/2021 03:04, Terry Reedy wrote: > > On 2/11/2021 3:22 PM, duncan smith wrote: > > > >>It seems that I can mutate a

Re: mutating a deque whilst iterating over it

2021-02-13 Thread Dan Stromberg
On Sat, Feb 13, 2021 at 10:25 AM duncan smith wrote: > On 12/02/2021 03:04, Terry Reedy wrote: > > On 2/11/2021 3:22 PM, duncan smith wrote: > > > >>It seems that I can mutate a deque while iterating over it if I > >> assign to an index, but not if I append to it. Is this the intended > >

Re: mutating a deque whilst iterating over it

2021-02-13 Thread duncan smith
On 12/02/2021 03:04, Terry Reedy wrote: > On 2/11/2021 3:22 PM, duncan smith wrote: > >>    It seems that I can mutate a deque while iterating over it if I >> assign to an index, but not if I append to it. Is this the intended >> behaviour? > > Does the deque doc say anything about mutation w

Re: mutating a deque whilst iterating over it

2021-02-12 Thread Terry Reedy
On 2/11/2021 3:22 PM, duncan smith wrote: It seems that I can mutate a deque while iterating over it if I assign to an index, but not if I append to it. Is this the intended behaviour? Does the deque doc say anything about mutation while iterating? (Knowing the author of deque, I would

Re: mutating a deque whilst iterating over it

2021-02-11 Thread Cameron Simpson
On 11Feb2021 20:22, duncan smith wrote: > It seems that I can mutate a deque while iterating over it if I >assign to an index, but not if I append to it. Is this the intended >behaviour? It seems a bit inconsistent. Cheers. I think that just means that the deque didn't _notice_ your change i

Re: mutating a deque whilst iterating over it

2021-02-11 Thread dn via Python-list
On 12/02/2021 09.22, duncan smith wrote: > Hello, > It seems that I can mutate a deque while iterating over it if I > assign to an index, but not if I append to it. Is this the intended > behaviour? It seems a bit inconsistent. Cheers. Yes, and no! Agree and disagree. (see how decisive I ca

mutating a deque whilst iterating over it

2021-02-11 Thread duncan smith
Hello, It seems that I can mutate a deque while iterating over it if I assign to an index, but not if I append to it. Is this the intended behaviour? It seems a bit inconsistent. Cheers. Duncan >>> from collections import deque >>> d = deque(range(8)) >>> it = iter(d) >>> next(it) 0 >>> d[1