Message52813
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.
|
|
Date |
User |
Action |
Args |
2007-08-23 15:58:57 | admin | link | issue1749857 messages |
2007-08-23 15:58:57 | admin | create | |
|