Allowing zero-dimensional subscripts

spam.noam at gmail.com spam.noam at gmail.com
Thu Jun 8 18:52:29 EDT 2006


Hello,

Terry Reedy wrote:
> > In a few more words: Currently, an object can be subscripted by a few
> > elements, separated by commas. It is evaluated as if the object was
> > subscripted by a tuple containing those elements.
>
> It is not 'as if'.   'a,b' *is* a tuple and the object *is* subcripted by a
> tuple.
> Adding () around the non-empty tuple adds nothing except a bit of noise.
>

It doesn't necessarily matter, but technically, it is not "a tuple".
The "1, 2" in "x[1, 2]" isn't evaluated according to the same rules as
in "x = 1, 2" - for example, you can have "x[1, 2:3:4, ..., 5]", which
isn't a legal tuple outside of square braces - in fact, it even isn't
legal inside parens: "x[(1, 2:3:4, ..., 5)]" isn't legal syntax.

Noam




More information about the Python-list mailing list