本文介绍了如何将制表符补全添加到Python Shell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用python manage.py shell
启动django应用程序时,我得到一个InteractiveConsole shell-我可以使用制表符补全,等等.
When starting a django application using python manage.py shell
, I get an InteractiveConsole shell - I can use tab completion, etc.
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
仅使用python
启动python解释器时,它不提供制表符补全.
When just starting a python interpreter using python
, it doesn't offer tab completion.
有人可以告诉我django在做些什么来给我一个交互式控制台吗,或者我需要做些什么来启动没有django应用程序的交互式控制台?
Can someone tell me what django is doing to give me an interactive console, or what I need to do to start an interactive console without a django app?
推荐答案
我可能已经找到一种解决方法.
I may have found a way to do it.
创建文件.pythonrc
Create a file .pythonrc
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
然后在您的.bashrc文件中,添加
then in your .bashrc file, add
export PYTHONSTARTUP=~/.pythonrc
这似乎行得通.
这篇关于如何将制表符补全添加到Python Shell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!