[Python-ideas] List Revolution

Steven D'Aprano steve at pearwood.info
Mon Sep 12 12:36:20 CEST 2011

mike.w.meyer at gmail.com wrote:
> Ok, how about enhancing the list type to allow specifying an offset,
> defaulting to 0? The offset should be positive, and that many
> elements simple aren't there. Asking for an element that isn't there,
> or a slice including such an element, raises value error exception.
> The iterators & etc for this list would all start at offset instead
> of zero.

I believe that Ada allows that. Any Ada users want to comment on how 
useful or annoying this is?

Another alternative would be to specify the indexing scheme at call 
time, rather than when you create the list. Something like:

item = mylist[7 starting from 5]

will set item to mylist[2] (using zero-based indexing). Best of all, 
with a slight change of syntax, that is available right now:

item = mylist[7-5]

and so we can simulate variable-offset indexing with no new syntax and 
only a very small run-time cost. Guido's time machine strikes again!



More information about the Python-ideas mailing list