IPython interactive shell output formatting configuration

安稳与你 提交于 2019-12-12 03:45:27

问题


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:


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]


来源:https://stackoverflow.com/questions/15232333/ipython-interactive-shell-output-formatting-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!