[Python-Dev] Bug or not? Different behaviour iterating list and collections.deque (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Mon Jan 8 01:37:23 CET 2007
- Previous message: [Python-Dev] Bug or not? Different behaviour iterating list andcollections.deque
- Next message: [Python-Dev] Bug or not? Different behaviour iterating list and collections.deque
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christos Georgiou schrieb:
Is that intentional?
It would have helped if you had said what "that" is you are referring to, it would also have helped if you had stated an opinion on whether you believe that to be a bug. For example, I think I would have phrased your post like this:
""" If I apply .next() to an iter of a deque that has been modified, I get a RuntimeError:
py> d=collections.deque() py> d.append(10) py> i=iter(d) py> d.append(10) py> i.next() Traceback (most recent call last): File "", line 1, in ? RuntimeError: deque mutated during iteration
Yet when I apply .next() to an iter of an initially-empty deque, I get StopIteration:
py> d=collections.deque() py> i=iter(d) py> d.append(10) py> i.next() Traceback (most recent call last): File "", line 1, in ? StopIteration
Is this a bug? Shouldn't the second example also raise the RuntimeError as the deque has been modified? (also, is appending an element a modification or a mutation?) """
To this question (.next on an iterator of a modified deque), my answer would be: "yes, that is a bug".
However, I feel you are referring to a different issue, unfortunately, I cannot tell from your post what that issue is.
Regards, Martin
- Previous message: [Python-Dev] Bug or not? Different behaviour iterating list andcollections.deque
- Next message: [Python-Dev] Bug or not? Different behaviour iterating list and collections.deque
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]