[Numpy-discussion] print array in a form that can then be input
Fernando Perez
fperez.net at gmail.com
Sat Oct 20 16:05:57 EDT 2012
On Sat, Oct 20, 2012 at 4:40 AM, Daπid <davidmenhur at gmail.com> wrote:
>>>> a=np.arange(10)
>>>> print a
> [0 1 2 3 4 5 6 7 8 9]
>>>> repr(a)
> 'array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])'
>
Note that you don't need to explicitly call repr() at the interactive
prompt: by default, Python prints the repr of an object when you type
its name:
In [24]: a=np.arange(10)
In [25]: repr(a)
Out[25]: 'array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])'
In [26]: a
Out[26]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
(this is ipython, but the behavior is the same in plain python).
Cheers,
f
More information about the NumPy-Discussion
mailing list