readline and TAB-completion?

Ulli Horlacher framstag at rus.uni-stuttgart.de
Wed Nov 25 02:02:06 EST 2015


I need an input function with GNU readline support. So far I have:

    import readline
    readline.parse_and_bind("tab: complete")

    file = raw_input('File to send: ')


Cursor keys are working, but TAB-completion works only in the current
directory. Example:


File to send: [TAB][TAB]
argv.py              error.py             md5b64.py            x.py
Python_Cookbook.pdf  bookmarks            fexit.py             murksigkeiten
_.py                 compile.py           https.py             wcp

File to send: /tmp/[TAB][TAB]
argv.py              error.py             md5b64.py            x.py
Python_Cookbook.pdf  bookmarks            fexit.py             murksigkeiten
_.py                 compile.py           https.py             wcp


Is there a way to make TAB-completion work for other directories, too?

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum IZUS/TIK         E-Mail: horlacher at tik.uni-stuttgart.de
Universitaet Stuttgart         Tel:    ++49-711-68565868
Allmandring 30a                Fax:    ++49-711-682357
70550 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/



More information about the Python-list mailing list