【发布时间】:2013-07-11 04:16:07
【问题描述】:
我知道我可以用这个:
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
在我的 python 解释器中启用 ipython 样式的选项卡完成。
我怎样才能让它在启动时默认运行,每当我启动 python 时?
【问题讨论】:
标签: python
我知道我可以用这个:
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
在我的 python 解释器中启用 ipython 样式的选项卡完成。
我怎样才能让它在启动时默认运行,每当我启动 python 时?
【问题讨论】:
标签: python
将其放入文件.pythonrc(您可以通过环境变量PYTHONSTARTUP控制该文件的名称)。阅读更多关于here:
PYTHONSTARTUP
If this is the name of a readable file, the Python commands
in that file are executed before the first prompt is displayed
in interactive mode. The file is executed in the same namespace
where interactive commands are executed so that objects defined
or imported in it can be used without qualification in the interactive
session. You can also change the prompts sys.ps1 and sys.ps2 in this file.
另见:
【讨论】:
readline 在 OS X 上是用libedit 实现的。你必须根据this answer 使用"bind ^I rl_complete"。
Just export PYTHONSTARTUP=$HOME/.pythonrc 就像您提到的其他答案一样?