FAQ
Hi


Am 31.10.2013 23:35, schrieb Terry Reedy:
On 10/31/2013 5:29 PM, Ulrich Goebel wrote:

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).
You are free to write such a class, if it is appropriate for your actual
use case.

Ok, possibly I will try that later...

If you have a concrete sequence object seq with random access, there is
no reason to do so. First and last are seq[0] and seq[-1]. Given
'cursor' i, prev and next are 'i-=1;seq[i]' and 'i+=1;seq[i]'.

That gives me the solution. What I have, is an iterator object comming
as a SQLite database cursor object. So I could minimize the underliying
SELECT and build index = list(cursor). Then with Your hints I get what I
want.


Thanks
Ulrich


--
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedNov 1, '13 at 10:18a
activeNov 1, '13 at 8:09p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase