ipython 不加新行
ipython do not add a new line
考虑 ipython 回复:
$ ipython
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
[ins] In [1]: x = 2
[ins] In [2]: y = 2
[ins] In [3]:
相比之下,考虑正常的python repl:
$ python
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 2
>>> y = 2
>>>
正如你所看到的,ipython repl 添加了很多不必要的(我认为)换行语句,而 python repl 则更加简洁。
有什么方法可以禁用这些新行吗? (请注意,我知道这一点:https://ipython.readthedocs.io/en/stable/config/details.html 可以更改提示中显示的内容。但是,我找不到禁用提示之间的新行的选项)
使用 --nosep
选项启动 ipython
。
$ ipython --nosep
Python 3.8.3 | packaged by conda-forge | (default, Jun 1 2020, 17:43:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: x = 1
In [2]: y = 2
In [3]: print(x, y)
1 2
In [4]:
来自ipython --help
:
--nosep
Eliminate all spacing between prompts.
也可以通过设置此配置选项来实现此行为:
c.InteractiveShell.separate_in = ''
考虑 ipython 回复:
$ ipython
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
[ins] In [1]: x = 2
[ins] In [2]: y = 2
[ins] In [3]:
相比之下,考虑正常的python repl:
$ python
Python 3.6.8 (default, Aug 7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 2
>>> y = 2
>>>
正如你所看到的,ipython repl 添加了很多不必要的(我认为)换行语句,而 python repl 则更加简洁。
有什么方法可以禁用这些新行吗? (请注意,我知道这一点:https://ipython.readthedocs.io/en/stable/config/details.html 可以更改提示中显示的内容。但是,我找不到禁用提示之间的新行的选项)
使用 --nosep
选项启动 ipython
。
$ ipython --nosep
Python 3.8.3 | packaged by conda-forge | (default, Jun 1 2020, 17:43:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: x = 1
In [2]: y = 2
In [3]: print(x, y)
1 2
In [4]:
来自ipython --help
:
--nosep
Eliminate all spacing between prompts.
也可以通过设置此配置选项来实现此行为:
c.InteractiveShell.separate_in = ''