Allowing zero-dimensional subscripts
apardon at forel.vub.ac.be
Fri Jun 9 15:51:07 CEST 2006
Op 2006-06-08, spam.noam at gmail.com schreef <spam.noam at gmail.com>:
> 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
>> 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".
Yes it is.
> The "1, 2" in "x[1, 2]" isn't evaluated according to the same rules as
> in "x = 1, 2"
I was pretty sure it was.
> - for example, you can have "x[1, 2:3:4, ..., 5]", which
> isn't a legal tuple outside of square braces
Yes it is, it just is illegal notation outside square brackets.
You could have approximate the same effect by
I = 1, slice(2,3,4), Ellipsis, 5
> - in fact, it even isn't
> legal inside parens: "x[(1, 2:3:4, ..., 5)]" isn't legal syntax.
But what is illegal is the notation, not the value.
More information about the Python-list