[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses

Alex Martelli aleaxit at gmail.com
Fri Jun 9 20:09:11 CEST 2006

On 6/9/06, Guido van Rossum <guido at python.org> wrote:
> The language doesn't have zero-dimensional arrays, although it doesn't
> prevent users from defining them. but why would one want to index a
> zero-dimensional array, since it has no dimensions? It should be
> written as x, not x[].

Well, x=23 on one side, and  x[]=23 aka x[()]=23 on the other, have
drastically different semantics. Indexing refers to the contents of
the zero-dimensional container, rather than to a name to which the
container happens to be bound (but isn't any more, once one assigns to
that name rather than to an indexing thereof).

That being said, having to write x[()]=23 explicitly (rather than
x[]=23) wouldn't perturb me overmuch, personally -- so, I don't see a
need to rush this at the last minute into 2.5 beta (rather than
letting the idea ripen with a target of 2.6).


More information about the Python-Dev mailing list