mutable list iterators - a proposal
Aahz
aahz at pythoncraft.com
Mon Mar 15 09:24:58 EST 2004
In article <e4e0340c.0403150334.4faeb3a3 at posting.google.com>,
Jess Austin <jaustin at post.harvard.edu> wrote:
>
>I like the way that Python does lists, and I love the way it does
>iterators. But I've decided I don't like what it does with iterators
>of lists. Lists are supposed to be mutable sequences, but try to use
>an iterator of a list that you're mutating and watch it all fall to
>pieces. That is, if you change the length of a section of the list
>through which the iterator has already passed, it will lose track of
>where it is. I think this should be fixed for 2.4. I'm not sure if
>this is a bug or a PEP, so I'd like to hear from others on this
>newsgroup.
I'll guarantee that it won't be fixed for 2.4. This subject has come up
many times long before iterators were introduced, and the answer has
always beent the same: if you want to mutate, make a copy or make *very*
sure that your mutations don't muck the loop.
>I hope this isn't in conflict with any previous irrevocable
>pronouncements. b-)
Your hope is in vain. ;-)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"usenet imitates usenet" --Darkhawk
More information about the Python-list
mailing list