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-December/058901.html below:

[Python-Dev] synchronized enumerate

[Python-Dev] synchronized enumerateNick Coghlan ncoghlan at gmail.com
Mon Dec 19 22:10:31 CET 2005
Chris or Leslie Smith wrote:
> Whenever I use enumerate, I am doing so because I will use the index to
> access some other element in the list (the previous or next, usually) while
> also looking at the element that is returned from enumerate.  Several
> times, however, in the development phase of the work, I end up sending a
> subset of the list at hand and then get bitten by the fact that the indices
> returned by enumerate are not the indices of the original list, they are
> the indices of the slice that I sent. e.g. in the following, "0" is the
> first index but I wanted it to be 3

a. What Aahz said (this is more a c.l.p./python-list question than a 
python-dev one)

b. It may be worth finding a way to use itertools.islice on the output of 
enumerate rather than slicing before the enumeration operation if you want the 
indices to line up with the original sequence rather than with the slice.

Cheers,
Nick.

P.S. I don't personally track c.l.p. (other than some of the threads that make 
it to python-url) so cc' my email address if you want to follow up on point b :)

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
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