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/2007-July/073782.html below:

[Python-Dev] itertools addition: getitem()

[Python-Dev] itertools addition: getitem() [Python-Dev] itertools addition: getitem()Walter Dörwald walter at livinglogic.de
Sun Jul 8 11:38:22 CEST 2007
I'd like to propose the following addition to itertools: A function 
itertools.getitem() which is basically equivalent to the following 
python code:

_default = object()

def getitem(iterable, index, default=_default):
    try:
       return list(iterable)[index]
    except IndexError:
       if default is _default:
          raise
       return default

but without materializing the complete list. Negative indexes are 
supported too (this requires additional temporary storage for abs(index) 
objects).

The patch is available at http://bugs.python.org/1749857

Servus,
    Walter
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