[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
Greg Ewing
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:
def outer():
x = array(0)
def inner():
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().
--
Greg
More information about the Python-Dev
mailing list