1

If there's a quick fix for this, apologies in advance. In the IPython shell, if I have this:

In [1]: x = [i for i in range(100)]

then I get a list printed with each element on a new line if I call it:

In [2]: x
Out[2]: [0
        1,
        2,

and so on down to 100. Irritating as hell because often I'm calling objects and don't know how long they'll be (and don't want to check beforehand, and don't want my last commands to get pushed up and out of the way). How can I get it to print that result the way it would in regular python? I.e.:

>>> x
[1,2,3,4,5,6,7,8,....
9,10,11, ..... 100]
1
  • sudo apt-get install bpython it's a better python repl, prints lists as you'd expect as a bonus.. Commented Mar 5, 2013 at 20:14

1 Answer 1

1

What you want is to disable pretty print.

$ ipython --help
[...]
--no-pprint
    Disable auto auto pretty printing of results.
[...]

Which gives :

$ ipython --no-pprint
[...]

In [1]: x = [i for i in range(100)]

In [2]: x
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
Sign up to request clarification or add additional context in comments.

1 Comment

You can also temporarily turn off the pretty printing if you have ipython already open by typing %pprint, then type that again to turn it back on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.