Python Feature Request: Allow changing base of member indices to 1
Terry Reedy
tjreedy at udel.edu
Sat Apr 14 19:10:42 EDT 2007
<samjnaa at gmail.com> wrote in message
news:1176546465.632410.52630 at w1g2000hsg.googlegroups.com...
| I would like to have something like "option base" in Visual Basic.
| IIRC it used to allow me to choose whether 0 or 1 should be used as
| the base of member indices of arrays. In Python, the same can be used
| with strings, lists, tuples etc.
If you access a sequence with an iterator, perhaps now the most common
case, the index base becomes an irrelevant internal detail.
If you only access a sequence with explicit indexes, you can treat it as
1-based by ignoring the first element. This has been a standard conversion
technique for a fewdecades.
If you do not like writing range(1,n+1), use def myrange(n): return
range(1,n+1). Interface conversion wrappers are another standard
technique.
Terry Jan Reedy
More information about the Python-list
mailing list