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

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Jun 10 01:48:22 CEST 2006

Noam Raphael wrote:

> This PEP suggests to allow the use of an empty subscript list, for
> example ``x[]``, which is currently a syntax error. It is suggested
> that in such a case, an empty tuple will be passed as an argument to
> the __getitem__ and __setitem__ methods. This is consistent with the
> current behaviour of passing a tuple with n elements to those methods
> when a subscript list of length n is used, if it includes a comma.

It's not, really -- unless other places where a tuple
can appear were changed likewise, e.g.

   x =

would have to assign an empty tuple to x, etc.

> But you may also have several
> zero-dimensional arrays, that is, single values - for example, the
> income tax rate.

But *why* do these need to be 0-dimensional arrays rather
than just scalars? I'm having trouble seeing any use
for such a distinction.

I'm particularly unconvinced by the spreadsheet argument.
In that context, I'd say that everything is a 2-D array,
and a single cell is a 1x1 2-D array, not a 0-D array.


More information about the Python-Dev mailing list