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

jamadagni samjnaa at gmail.com
Sat Apr 14 09:39:59 EDT 2007


On Apr 14, 4:01 pm, "Martin v. Löwis" <mar... at v.loewis.de> wrote:

> This one is not sane. It's not possible to change the indexing of
> objects on a per-module basis, as objects may cross module boundaries.

I do not request for this to be changed per-module. Once I say
something like:

from __future__ import indices_start_at_one

afterwards I would expect *any* index from *any* module to start at 1.
To my understanding, Python is going to parse the content of modules
only as and when they are called. So Python is basically reading the
content of those modules when the flag of indices_start_at_one is
active, and hence I would expect it to start counting at 1.

I can envisage, stemming from your comments, that this can lead to
trouble when a module being accessed has hard-coded indices. It would
not be fair of me to expect all module writers to declare the base
option at the head of each file, though it would be good practice. So
the solution is to allow the programmer to choose to limit this tag
locally or activate it globally.

option base 1 local
option base 1 global




More information about the Python-list mailing list