A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/065773.html below:

Allow Empty Subscript List Without Parentheses

[Python-Dev] Pre-PEP: Allow Empty Subscript List Without ParenthesesTim Hochberg tim.hochberg at ieee.org
Fri Jun 9 20:09:22 CEST 2006
Guido van Rossum wrote:
> On 6/9/06, Nicko van Someren <nicko at nicko.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[].

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. Thus "a[()] = 3" will set the value of a 0-D array to 
3 and "a[()]" will extract the current, scalar value of a, for instance 
if you need a hashable object.

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.

[...]


-tim

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4