[Python-Dev] Allowing slicing of iterators
Steven Bethard
steven.bethard at gmail.com
Tue Jan 25 22:20:24 CET 2005
Raymond Hettinger <python at rcn.com> 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 reading this right, the difference between
sequence slicing and iterator slicing is a single-quote? IMVHO,
that's pretty hard to read...
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? Then
getslice(lst, lo, hi)
would just be an alias for
lst[lo:hi]
and
getslice(itr, lo, hi)
would just be an alias for
itertools.islice(itr, lo, hi)
Steve
--
You can wordify anything if you just verb it.
--- Bucky Katt, Get Fuzzy
More information about the Python-Dev
mailing list