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

faulkner faulkner891 at gmail.com
Sat Apr 14 15:09:04 EDT 2007


On Apr 14, 6:27 am, samj... at gmail.com wrote:
> 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.

__future__ is used to access upcoming features, and changing the base
offset is not [and never will be] slated for future development. zero
has been used as the base offset in all real languages since the dawn
of time, and isn't something that can be changed without seriously
breaking heads.

i can't believe nobody's posted this yet:
http://www.xkcd.com/c163.html




More information about the Python-list mailing list