Andreas Kraemer <[EMAIL PROTECTED]> wrote: >> The only other behaviours I would regard as intuitive for iteration over >> a mutating sequence would be to throw an exception either for mutating >> the sequence while the iterator exists or for using the iterator after a >> mutation. > > Maybe it would have been slightly more intuitive if reversed() had > been implemented like this, > > def Reversed(seq): > for i in xrange(len(seq)-1,-1,-1): > yield seq[i] > > so that the length of the sequence is determined when the iteration > starts, not when the iterator is created?
Perhaps, but either way it comes down to "don't modify the sequence while iterating". -- http://mail.python.org/mailman/listinfo/python-list