问题:禁用IPython退出确认

每次输入时exit(),系统都会提示我退出提示,这真令人烦恼。我当然要退出!否则,我不会写exit()

有没有一种方法可以覆盖IPython的默认行为,使其在没有提示的情况下退出?

It’s really irritating that every time I type exit(), I get prompted with a confirmation to exit; of course I want to exit! Otherwise, I would not have written exit()!!!

Is there a way to override IPython’s default behaviour to make it exit without a prompt?


回答 0

如果您还想Ctrl-D不经确认就退出,请在IPython 0.11中将其添加c.TerminalInteractiveShell.confirm_exit = False到配置文件*中。

如果还没有配置文件,请运行ipython profile create以创建一个。

如果您在Django Shell中工作,请注意此票证


*配置文件位于: $HOME/.ipython/profile_default/ipython_config.py

If you also want Ctrl-D to exit without confirmation, in IPython 0.11, add c.TerminalInteractiveShell.confirm_exit = False to your config file *.

If you don’t have a config file yet, run ipython profile create to create one.

Note this ticket if you’re working within the Django shell.


* The config file is located at: $HOME/.ipython/profile_default/ipython_config.py


回答 1

在ipython版本0.11或更高版本中,

  1. --no-confirm-exitOR 运行
  2. 通过“退出”退出,而不是按Control-D或
  3. 确保目录存在(或运行该目录ipython profile create)并将这些行添加到$ HOME / .ipython / profile_default / ipython_config.py:

    c = get_config()
    
    c.TerminalInteractiveShell.confirm_exit = False

In ipython version 0.11 or higher,

  1. Run with --no-confirm-exit OR
  2. Exit via ‘exit’ instead of control-D OR
  3. Make sure the directory exists (or run ipython profile create to create it) and add these lines to $HOME/.ipython/profile_default/ipython_config.py:

    c = get_config()
    
    c.TerminalInteractiveShell.confirm_exit = False
    

回答 2

只是打字Exit,有资本E

或者,通过以下方式启动IPython:

$ ipython -noconfirm_exit

或对于较新版本的IPython:

$ ipython --no-confirm-exit 

just type Exit, with capital E.

Alternatively, start IPython with:

$ ipython -noconfirm_exit

Or for newer versions of IPython:

$ ipython --no-confirm-exit 

回答 3

我喜欢配置建议,但是直到了解它们,我才开始使用“ Quit”组合键。

Ctrl+\

要么

Ctrl+4

这只会杀死正在运行的东西。没有时间提出确认问题。

I like the config suggestions, but until I learned them I’ve started using “Quit” key combination.

Ctrl+\

or

Ctrl+4

This just kills what is running. No time to ask questions on confirmation.


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。