Iterators: Would "rewind" be a good idea?

Charles D Hixson charleshixsn at earthlink.net
Sun May 21 15:43:33 EDT 2006


I was reading through old messages in the list and came up against an
idea that I thought might be of some value:
"Wouldn't it be a good idea if one could "rewind" an iterator?"
Not stated in precisely those terms, perhaps, but that's the way I read it.

I appreciate that one could use a sequence rather than an iterator, and
that I don't understand the implementation issues.  (They don't look
large, but what to I know?)

But would it be a good idea to have a rewind method for iterators?  I
tend to think of them as mag tapes, and I was always wanting to rewind
those.  Or skip to file n.  (Well, that probably doesn't have any
relevance to the usage of iterators.)

OTOH, if this is a bother, it's almost always quite easy to create a new
iterator, it just feels less efficient.  Still, I would use this much
more often that I would use reversed (which I've never wanted to use).



More information about the Python-list mailing list