# [SciPy-User] ERROR : while finding size

Christopher Barker Chris.Barker@noaa....
Thu Mar 3 13:38:13 CST 2011

```On 3/3/11 1:17 AM, Hector wrote:
>  The point I would
> like to highlight is that, raw input returns the *string* and hence may
> not be very useful if you are looking for an matrix input.

indeed. you may be better off with input(), which does evaluate the
expression and return the appropriate python object:

In [30]: x = raw_input()
[1,2,3,4]

In [31]: x
Out[31]: '[1,2,3,4]'

#so x is a string -- probably not what you want here.

In [32]: x = input()
[1,2,3,4]

In [33]: x
Out[33]: [1, 2, 3, 4]

# now x is a list-- more likely what you want:

In [34]: len(x)
Out[34]: 4

In [35]: x = input()
np.array([1,2,3,4])

In [36]: x
Out[36]: array([1, 2, 3, 4])

In [37]: x.shape
Out[37]: (4,)

now x is a numpy array, most likely what you want, but a bit awkward for
users, but there is nopython lieterl notation for arrays -- only lists
and tuples.

# perhaps you can write it this way:
In [38]: x = np.array(input())
[1,2,3,4]

In [39]: x
Out[39]: array([1, 2, 3, 4])

which gives you an array. You can get 2-d (and higher) arrays this way:

In [40]: x = np.array(input())
[[1,2,3], [4,5,6]]

In [41]: x
Out[41]:
array([[1, 2, 3],
[4, 5, 6]])

In [42]: x.shape
Out[42]: (2, 3)

HTH,
-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov
```