Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Readline functionality on windows with python 2.7

I need to import the readline functionality in a program written in python. I am currently using version 2.7 and the 3rd party packages I have seen only work up to version 2.6. Does anyone know of a 3rd party readline package for Windows with Python 2.7?

like image 373
Franz Payer Avatar asked May 17 '11 00:05

Franz Payer


2 Answers

I believe pyreadline was designed just for this.

easy_install pyreadline
or:
pip install pyreadline

http://pypi.python.org/pypi/pyreadline

Also, use the following for forward/reverse compatibility:

try:
  import readline
except ImportError:
  import pyreadline as readline
like image 161
Ben Burns Avatar answered Nov 06 '22 02:11

Ben Burns


Unfortunately, in 2019, pyreadline isn't really developed anymore.

It's far from a "drop-in" replacement, but you could look into Python Prompt Toolkit. It provides tab-completion and then some on just about every platform there is. If you're still using Python 2, you really should upgrade but the Prompt Toolkit does appear to support Python 2 with from __future__ import unicode_literals.

like image 4
c-x-berger Avatar answered Nov 06 '22 00:11

c-x-berger