0

In the python command line, I can do

>>> a array([ 0, 1, 3, 10, 1, 0, 0, 3, 6]) >>> print a [ 0 1 3 10 1 0 0 3 6] 

But in a .py file, I can only do print, but not directly 'a'. What if I want to see the whole array([ 0, 1, 3, 10, 1, 0, 0, 3, 6])?

4
  • What type is array, exactly? Is it the Python array type? Commented Apr 26, 2014 at 21:39
  • print 'array(%s)' % a. Commented Apr 26, 2014 at 21:42
  • The python CLI is a read-eval-print loop: see REPL Commented Apr 26, 2014 at 21:43
  • @JonathonReinhart: judging by the str(a) it is a numpy array. Commented Apr 27, 2014 at 1:45

1 Answer 1

5

The interpreter usually shows what repr(object) returns, so:

print repr(a) 

Example:

In [1]: import numpy as np In [2]: a = np.array([ 0, 1, 3, 10, 1, 0, 0, 3, 6]) In [3]: repr(a) Out[3]: 'array([ 0, 1, 3, 10, 1, 0, 0, 3, 6])' 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.