简体   繁体   中英

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.

How can I make this run by default on start, anytime I start python?

Put that into a file .pythonrc (You can control the name of that file by the environment variable 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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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