简体   繁体   English

默认选项卡完成,如python控制台中的ipython

[英]default tab completion like ipython in python console

I know I can use this: 我知道我可以用这个:

import rlcompleter, readline
readline.parse_and_bind('tab: complete')

to enable ipython-style tab completion in my python interpreter. 在我的python解释器中启用ipython样式的选项卡完成。

How can I make this run by default on start, anytime I start python? 我怎样才能在启动时默认运行,只要我启动python?

Put that into a file .pythonrc (You can control the name of that file by the environment variable PYTHONSTARTUP ). 将它放入文件.pythonrc (您可以通过环境变量PYTHONSTARTUP控制该文件的名称)。 Read more about 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.

see also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM