码迷,mamicode.com
首页 > 编程语言 > 详细

给python2.6的交互模式加一个TAB补全

时间:2018-03-08 18:06:50      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:python

首先新建一个tab.py文件
duwens-MacBook-Air:~ duwen$ cd /Library/Python/2.7/site-packages/
duwens-MacBook-Air:site-packages duwen$ sudo touch tab.py
Password:
duwens-MacBook-Air:site-packages duwen$ vim tab.py 
duwens-MacBook-Air:site-packages duwen$ sudo vim tab.py 

内容是:

import sys
import readline
import rlcompleter

if sys.platform == ‘darwin‘ and sys.version_info[0] == 2:
 ? ?readline.parse_and_bind("bind ^I rl_complete")
else:
 ? ?readline.parse_and_bind("tab: complete")

设置好环境变量,并编译

duwens-MacBook-Air:~ duwen$ vim ~/.bash_profile 
duwens-MacBook-Air:~ duwen$ source ~/.bash_profile

添加的内容是

export PYTHONSTARTUP=/Library/Python/2.7/site-packages/tab.py

给python2.6的交互模式加一个TAB补全

标签:python

原文地址:http://blog.51cto.com/duwers/2084308

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!