A RetroSearch Logo

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

Search Query:

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

[Python-Dev] Allowing slicing of iterators

[Python-Dev] Allowing slicing of iterators [Python-Dev] Allowing slicing of iteratorsGuido van Rossum gvanrossum at gmail.com
Mon Jan 24 16:25:27 CET 2005
> 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 example, here's how to skip the head of a zero-numbered list:
> 
>    for i, item in enumerate("ABCDEF")[1:]:
>      print i, item
> 
> Is this idea a non-starter, or should I spend my holiday on Wednesday finishing
> it off and writing the documentation and tests for it?

Since we already have the islice iterator, what's the point? It seems
to me that introducing this notation would mostly lead to confuse
users, since in most other places a slice produces an independent
*copy* of the data.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
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