Python Feature Request: Allow changing base of member indices to 1

samjnaa at gmail.com samjnaa at gmail.com
Sat Apr 14 06:27:45 EDT 2007


This is like the previous one. Please check for sanity and approve for
posting at python-dev.

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.

This would mean:
foo = "foo"
=> foo[1] == 'f'

foo = ['foo', 'bar', 'spam' ]
=> foo[1] == 'foo'

foo = ('spam', 'eggs')
=> foo[1] == 'spam'

For convenience it should also affect the range function so that:

range(3) = [1, 2, 3]

because this is often used where arrays would be used in VB.

Finally, when the programmer does not specify his choice of base at
the beginning of the program, the current behaviour of using 0 as base
should continue so that there is no problem with backward
compatibility.




More information about the Python-list mailing list