mac 终端下设置python tab键功能
2015-07-14 22:12
871 查看
import readline,rlcompleter
### Indenting
class TabCompleter(rlcompleter.Completer):
"""Completer that supports indenting"""
def complete(self, text, state):
if not text:
return (' ', None)[state]
else:
return rlcompleter.Completer.complete(self, text, state)
readline.set_completer(TabCompleter().complete)
### Add autocompletion
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind -e")
readline.parse_and_bind("bind '\t' rl_complete")
else:
readline.parse_and_bind("tab: complete")
### Add history
import os
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
del histfile
本文出自 “精忠报国” 博客,谢绝转载!
### Indenting
class TabCompleter(rlcompleter.Completer):
"""Completer that supports indenting"""
def complete(self, text, state):
if not text:
return (' ', None)[state]
else:
return rlcompleter.Completer.complete(self, text, state)
readline.set_completer(TabCompleter().complete)
### Add autocompletion
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind -e")
readline.parse_and_bind("bind '\t' rl_complete")
else:
readline.parse_and_bind("tab: complete")
### Add history
import os
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
del histfile
本文出自 “精忠报国” 博客,谢绝转载!
相关文章推荐
- IndentationError: unexpected indent python
- [Python]Django部署问题
- Python 无法显示行号(下)
- Python中time,datetime模块的常见使用方法
- python基础教程总结5——函数
- python import 的陷阱
- python import 包导入的陷阱
- Python Idle 无法显示行号(上)
- The C Programming Language Example and Python Implemented
- Python Security 之 端口扫描
- 图解Python深拷贝和浅拷贝
- 学习Python
- Python基础之变量类型
- Python日志输出——logging模块
- python 区分图像大小(A2、A3、A4)
- python基础教程总结4—基本语句
- 关于liaoxuefeng的python3教程实战第四天
- Python下opencv使用笔记(九)(图像直方图)
- Python监控进程性能数据并绘图保存为PDF文档
- python tornado 搭建webServer