Python tab 补全

1. 先准备一个tab.py的脚本

shell> cat tab.py


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19


#!/usr/bin/python

# python tab file

 

import sys

import readline

import rlcompleter

import atexit

import os

# tab completion

readline.parse_and_bind(‘tab: complete‘)

# history file

histfile = os.path.join(os.environ[‘HOME‘], ‘.pythonhistory‘)

try:

    readline.read_history_file(histfile)

except IOError:

    pass

atexit.register(readline.write_history_file, histfile)

 

del os, histfile, readline, rlcompleter

2. 查看Python默认的模块存放地址


1

2

3

4

5

6

7


[[email protected] ~]# python

Python 2.6.6 (r266:84292, Nov 22 201312:16:22)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help""copyright""credits" or "license" for more information.

>>> import sys

>>> sys.path

[‘‘, ‘/usr/lib64/python26.zip‘, ‘/usr/lib64/python2.6‘, ‘/usr/lib64/python2.6/plat-linux2‘, 

3. 拷贝该脚本到默认模块存放路径


1

cp tab.py  /usr/lib64/python2.6/

4. 现在可以用了

时间: 2024-07-29 01:43:05

Python tab 补全的相关文章

mac pro python tab补全脚本

之前习惯在win或者linux 下写python小脚本,经常先把tab补全环境配置好,到了mac下发现之前在linux下的tab.py脚本都不适用,自己参考了mac python tab补全的官网略微修改了下,发现蛮好用的. mac pro 下配置的是全局的,不需要再终端输入:python  =>import tab.py  ,这样完全没必要. 具体的mac tab 补全脚本参考下面: $ cat ~/.pythonstartup #-*- coding:utf-8 -*- import os,

python tab补全

让python的交互解释器支持tab补全.提示功能 方法1: 一.执行python脚本 1.创建一个python脚本,以.py结尾: 脚本如下: import sys import readline import rlcompleter import atexit import os readline.parse_and_bind('tab:complete') histfile =os.path.join(os.environ['HOME'], '.pythonhistory') try: r

linux下Python tab补全功能代码

1.在学习linux的童鞋都用惯了tab补全功能,从而在学习Python的同时,一是为了方便,二是可以看到更多的关于Python命令下的知识. 2.配置步骤: (1) 在linux下键入这样的代码: vim tab.py #!/usr/bin/python # python tab file import sys import readline import rlcompleter import atexit import os #tab completion readline.parse_an

Red Hat 7下python tab补全

最近学习python,总结一下如何添加shell脚本,达到(对象.)时,tab按2下调用所有方法的出现. 1.首先在目录:/usr/lib64/python2.7/site-packages下面建立vim tab.py文件. 2.tab.py文件下面的内容: #!/usr/bin/python import os import readline import rlcompleter import atexit import os # tab completion readline.parse_a

Mac或者linux系统自动加载python tab补全功能

因为mac OS属于类unix系统,所以基本和linux系统使用相差不大,只是用户登陆时自动执行环境变量文件的区别 mac系统: ShanedeMBP:login_api shane$ vi ~/.bash_profile linux系统: [[email protected] ~]# ls -a .bash* .bash_history .bash_logout .bash_profile .bashrc linux中有bash_profile,bashrc,以下是区别: /etc/profi

unbtun python tab补全

在使用python的时候有时候总是忘记很多代码,这个是作为程序袁最头疼的事情,本人也是刚刚接触python,这几天也是用到这块,所以记录下来,已被需要时能够找到. 我的系统是: [email protected]:~$ uname -a Linux w 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 先看看自己的python安装路径,如果不知道的话可以根据下面的方

linux python tab 补全

第一步:查看python系统路径 [[email protected] tools]# python Python 2.7.12 (default, Jul  4 2016, 02:08:58)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2 Type "help", "copyright", "credits" or "license" for more informat

Python tab补全命令

#!/usr/bin/env python #-*-UTF-8-*- #!/usr/bin/python # python startup file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete') # history file histfile = os.path.join(os.envir

在vim编辑器python实现tab补全功能

在vim编辑器中实现python tab补全插件有Pydiction,Pydiction可以实现下面python代码的自动补全: 1. 简单python关键词补全 2. python函数补全带括号 3. python模块补全 4. python模块内函数,变量补全 5. from module import sub-module补全 第一步:安装配置pydiction $ wget https://github.com/rkulla/pydiction/archive/master.zip $