[Python-Dev] Re: PEP 279 revisited

Alex Martelli aleax@aleax.it
Wed, 24 Apr 2002 16:25:39 +0200

On Wednesday 24 April 2002 03:37 pm, Neil Schemenauer wrote:
> Greg Ewing wrote:
> > There doesn't seem to be any single English word that
> > captures all of what we mean without ambiguity.
> How about "indices"?  You use a key to get things out of dictionaries.
> You use an index to get things out of sequences.  "indices" is the pural
> of index.

Yes, but it's a noun, not a verb.  Again, I don't understand why this
type's name should be a verb, but apparently that's the Decision --
we're only being consulted on "which verb".

Apart from this, "indices" suggests you're getting ONLY indices --
while when you iterate on this type you get indices AND contents.

In other words, name "indices" might be fine for a hypothetical
different type, for usage such as:

    for i in indices(mysequence):
        x = mysequence[i]
        # etc

rather than the current:

    for i in xrange(len(mysequence)):
        x = mysequence[i]
        # etc

but the type RH and I implemented (not without help from GvR in
fixing the mess I'd made of GC &c:-) is to be used differently:

    for i, x in mysterynamegoeshere(mysequence_or_other_iterator):
        # just the etc -- x, the i-th value, is already in hand