IPython交互式shell输出格式配置

时间:2013-03-05 19:21:37

标签: ipython linewrap

如果有快速解决方法,请提前道歉。在IPython shell中,如果我有这个:

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

然后,如果我调用它,我会在新行上打印出每个元素的列表:

In [2]: x
Out[2]: [0
        1,
        2,
因为经常我正在调用对象并且不知道它们会有多长时间(并且不想事先检查,并且不希望我的最后命令被推开并且不受阻碍)。我怎样才能让它以普通python的方式打印出结果呢?即:

>>> x
[1,2,3,4,5,6,7,8,....
9,10,11, ..... 100]

1 个答案:

答案 0 :(得分:1)

你想要的是禁用漂亮的打印。

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

给出了:

$ 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]