2024-06-26 13:03:26 发布
网友
ipython documentation有一长串可配置选项。一些用于TerminalInteractiveShell,一些用于InteractiveShell。当我从命令行生成一个ipython_config.py时,一些选项出现在文档中的一个选项和另一个选项中。这有什么道理吗?两者兼有的原因是什么
TerminalInteractiveShell
InteractiveShell
ipython_config.py
通过查看文档中的list of modules,我们发现
IPython.core.application: An application for IPython.IPython.core.interactiveshell: Main IPython class.IPython.terminal.ipapp: The Application object for the command line ipython program.IPython.terminal.interactiveshell: IPython terminal interface using prompt_toolkit
IPython.core.application: An application for IPython.
IPython.core.application
IPython.core.interactiveshell: Main IPython class.
IPython.core.interactiveshell
IPython.terminal.ipapp: The Application object for the command line ipython program.
IPython.terminal.ipapp
ipython
IPython.terminal.interactiveshell: IPython terminal interface using prompt_toolkit
IPython.terminal.interactiveshell
^{}是基本的iPython外壳类,可以为不同的目的对其进行子类化^{}就是这样一个特殊的子类。它继承自InteractiveShell,是在命令行中键入“ipython”时运行的特定shell
一个可用于TerminalInteractiveShell但不是的配置选项的示例是InteractiveShell基^{}。这似乎是合理的,因为“你真的想退出吗”这个问题只有在外壳内有人按下Control-D时才真正相关
实际上,如果您只是试图配置命令行ipythonshell,那么更改选项的InteractiveShell或TerminalInteractiveShell版本都会起作用,因为TerminalInteractiveShell继承了基类的选项。但是,只编辑更具体的TerminalInteractiveShell类更安全,因为基类仍然在非终端情况下使用,更改其设置可能会导致意外行为。例如:
This Jupyter Notebook tutorial使用InteractiveShell将笔记本代码单元转换为可执行Python
ipython源代码中的This test class为每个测试创建一个shell(从普通InteractiveShell继承)
希望这是有帮助的
通过查看文档中的list of modules,我们发现
^{} 是基本的iPython外壳类,可以为不同的目的对其进行子类化^{} 就是这样一个特殊的子类。它继承自
InteractiveShell
,是在命令行中键入“ipython”时运行的特定shell一个可用于} 。这似乎是合理的,因为“你真的想退出吗”这个问题只有在外壳内有人按下Control-D时才真正相关
TerminalInteractiveShell
但不是的配置选项的示例是InteractiveShell
基^{实际上,如果您只是试图配置命令行ipythonshell,那么更改选项的
InteractiveShell
或TerminalInteractiveShell
版本都会起作用,因为TerminalInteractiveShell
继承了基类的选项。但是,只编辑更具体的TerminalInteractiveShell
类更安全,因为基类仍然在非终端情况下使用,更改其设置可能会导致意外行为。例如:This Jupyter Notebook tutorial使用
InteractiveShell
将笔记本代码单元转换为可执行Pythonipython源代码中的This test class为每个测试创建一个shell(从普通
InteractiveShell
继承)希望这是有帮助的
相关问题 更多 >
编程相关推荐