Guido van Rossum wrote:
Iterators are for single sequential access. It's a feature that you
have to import itertools (or at least that you have to invoke its
special operations) -- iterators are not sequences and shouldn't be
confused with such.
I agree the semantic difference between an iterable
[me]
Since we already have the islice iterator, what's the point?
[Nick]
I'd like to see iterators become as easy to work with as lists are. At the
moment, anything that returns an iterator forces you to use the relatively
cumbersome itertools.islice mechanism, rather than Python's native
Nick Coghlan wrote:
In the example below (printing the first 3 items of a sequence), the fact that
sorted() produces a new iterable list, while reversed() produces an iterator
over the original list *should* be an irrelevant implementation detail from
the
programmer's point of view.
You
Nick Coghlan [EMAIL PROTECTED] wrote:
Guido van Rossum wrote:
Since we already have the islice iterator, what's the point?
I'd like to see iterators become as easy to work with as lists are. At the
moment, anything that returns an iterator forces you to use the relatively
cumbersome
Raymond Hettinger [EMAIL PROTECTED] wrote:
FWIW, someone (Bengt Richter perhaps) once suggested syntactic support
differentiated from sequences but less awkward than a call to
itertools.islice().
itertools.islice(someseq, lo, hi) would be rendered as someseq'[lo:hi].
Just to make sure I'm
Steven Bethard wrote:
If we're really looking for a builtin, wouldn't it be better to go the
route of getattr/setattr and have something like getslice that could
operate on both lists and iterators?
Such a builtin should probably be getitem() rather than getslice() (since
getitem(iterable,
I just wrote a new C API function (PyItem_GetItem) that supports slicing for
arbitrary iterators. A patch for current CVS is at http://www.python.org/sf/1108272
For simple indices it does the iteration manually, and for extended slices it
returns an itertools.islice object.
As a trivial
I just wrote a new C API function (PyItem_GetItem) that supports slicing for
arbitrary iterators. A patch for current CVS is at
http://www.python.org/sf/1108272
For simple indices it does the iteration manually, and for extended slices it
returns an itertools.islice object.
As a trivial