"Backward"-Iterator - Beginners question

Dan Stromberg drsalists at gmail.com
Fri Nov 1 00:26:12 CET 2013


On Thu, Oct 31, 2013 at 2:29 PM, Ulrich Goebel <ml at fam-goebel.de> wrote:

> Hallo,
>
> I'm locking for an "iterator" type with not only the .next() method, but
> with a .previous(), .first() and .last() method, so that I can through it
> from the beginning or from the end, and in both directions, even
> alternately (for example two steps forward, one backward, two steps
> forward).
>

I'm thinking maybe you want a list.

EG:
   list_ = list(my_iterator())
   i = 0
   print list_[i]
   i += 1
   print list_[i]
   print list_[i-1]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131031/edb556d2/attachment.html>


More information about the Python-list mailing list