[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
greg.ewing at canterbury.ac.nz
Sat Jun 10 02:02:30 CEST 2006
Tim Hochberg wrote:
> In Numpy, a 0-D array [for example, array(5)] is almost, but not quite,
> equivalent to scalar [for example, 5]. The difference is that the
> former is mutable.
Hmmm, I hadn't considered that. I suppose this is
something that arises from NumPy's "view" semantics
of indexing and slicing.
> Whether that makes x desirable I won't venture an opinion. I don't see
> a lot of use of 0-D arrays in practice.
Actually, I *have* just thought of a use for it:
x = array(0)
x = 42
Bingo - write access to outer scopes!
Okay, I'm +0 on this now. But for that use, we'd need
a more convenient way of creating one than importing
NumPy and using array().
More information about the Python-Dev