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

John Machin sjmachin at lexicon.net
Sat Apr 14 16:49:51 EDT 2007


On Apr 14, 8:27 pm, 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.

+1 F***ed Concept of the Year





More information about the Python-list mailing list