A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-January/051289.html below:

[Python-Dev] Allowing slicing of iterators

[Python-Dev] Allowing slicing of iterators [Python-Dev] Allowing slicing of iteratorsJosiah Carlson jcarlson at uci.edu
Tue Jan 25 21:57:39 CET 2005
Nick Coghlan <ncoghlan at iinet.net.au> 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 itertools.islice mechanism, rather than Python's native slice syntax.


If you want to use full sequence slicing semantics, then make yourself a
list or tuple. I promise it will take less typing than itertools.islice()
(at least in the trivial case of list(iterable)). Using language syntax
to pretend that an arbitrary iterable is a list or tuple may well lead
to unexpected behavior, whether that behavior is data loss or a caching
of results.  Which behavior is desireable is generally application
specific, and I don't believe that Python should make that assumption
for the user or developer.

 - Josiah

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4