[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses (original) (raw)

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


Alex Martelli wrote:

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).

It's not clear to me that a 0-D array should be regarded as a container holding a single item, rather than just an item on its own.

Think about how you get from an N dimensional array to an N-1 dimensional array: you index it, e.g.

A2 = [[1, 2], [3, 4]] # a 2D array

A1 = A2[1] # a 1D array

A0 = A1[1] # a 0D array???

print A0

What do you think this will print?

-- Greg



More information about the Python-Dev mailing list