Chinaunix首页 | 论坛 | 博客
  • 博客访问: 250527
  • 博文数量: 65
  • 博客积分: 2599
  • 博客等级: 少校
  • 技术积分: 710
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-04 10:49
文章分类

全部博文(65)

文章存档

2015年(4)

2013年(2)

2012年(4)

2011年(51)

2010年(4)

分类: Python/Ruby

2013-04-11 17:30:20

首先,了解一个环境变量:
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 name space 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.
所以,我们可以指定一个文件为Python的命令行作配置!
可以在文件中写入任何想要的配置,当然可以进行tab自动补全:
创建~/.pythonconf,写入内容:
import readline, rlcompleter
readline.parse_and_bind("tab: complete")

然后在~/.bashrc中添加环境变量PYTHONSTARTUP:
PYTHONSTARTUP=~/.pythonconf
export PYTHONSTARTUP

source ~/.bashrc
就可以了,以后每次登陆之后,python在shell里面就能够自动补全了。
阅读(5656) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

xiaodylan2013-04-12 11:12:33

不错。
你好想问一下,我想实现raw_input 读入的时候 可以试用tab来获取当前目录下的文件 像shell的 tab补全