This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients
Date 2007-07-31.07:03:40
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Rejected after an offline discussion with the OP.

The use case for getitem(n) with n as a negative number depended on an unlikely combination of circumstances:

* you have an iterable that is not a sequence (otherwise, just use s[-n]).
* the iterable is somewhat large (otherwise, just list it into memory)
* the iterable is finite (otherwise, getitem() dies in a infinite loop)
* you only want one entry (otherwise, you'll have make multiple passes)
* that entry is located near the end (otherwise getitem() is memory intensive)
* you know the entry's offset from the end but not from the beginning
* identifying the record of interest depends only on its position, not its content

In the common case where the index is zero, the preferred spelling is to use the next() method -- that is its purpose.  For cases where the index is a positive integer, uing islice(it, n).next() suffices though it doesn't have the cute feature for a default value.

History
Date User Action Args
2007-08-23 15:58:57adminlinkissue1749857 messages
2007-08-23 15:58:57admincreate