[Numpy-discussion] About asarray (list)

Pauli Virtanen pav at iki.fi
Wed Aug 27 10:55:18 EDT 2008


Wed, 27 Aug 2008 16:48:48 +0200, Claude Gouedard wrote:

> Hi ,
> 
> I'm just surprised by the behaviour of numpy.asarray on  lists.
> 
> Can someone comment this :
> =====================
> a=(1)
> aa=asarray(a)
> print  aa.size , aa.shape
>>> 1   ( )
> =====================

() are not list delimiters in Python; [] are, see [1,2]:

>>> a = (1)
>>> type(a)
<type 'int'>
>>> a = [1]
>>> type(a)
<type 'list'>

.. [1] http://docs.python.org/tut/node5.html#SECTION005140000000000000000
.. [2] http://docs.python.org/tut/node7.html#SECTION007300000000000000000

-- 
Pauli Virtanen




More information about the NumPy-Discussion mailing list