[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
Alex Martelli
aleaxit at gmail.com
Sat Jun 10 05:25:31 CEST 2006
More information about the Python-Dev mailing list
Sat Jun 10 05:25:31 CEST 2006
- Previous message: [Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
- Next message: [Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Jun 9, 2006, at 4:55 PM, Greg Ewing wrote:
...
> 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?
Don't confuse arrays with lists...:
>>> A2 = Numeric.array([[1, 2], [3, 4]], Numeric.Float32)
>>> A1 = A2[1]
>>> A0 = A1[1]
>>> type(A0)
<type 'array'>
>>>
It doesn't work the same if you specify Numeric.Float64 instead -- an
ancient wart of Numeric, of course. Still, Numeric and its
descendants are "the" way in Python to get multi-dimensional arrays,
since the stdlib's array module only supports one-dimensional ones,
and lists are not arrays.
Alex
- Previous message: [Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
- Next message: [Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list