473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using gnu readline in my own python program?

Hi...I'm a newbie to python, and very confused. I'm writing a simple
program and want the user to be able to edit a line that I display
using the full gnu readline capabilitites. (For example, control+a to
go to the beginning of the line.)

Then I want to be able to read the line after it's been edited...

I know that with perl I would do this with some variation on
term::readline.

I've looked at the readline and code packages under Python but I can't
make heads or tails of them. The readline example in the docs is way
over my head.

Any ideas?

Thanks

Aug 1 '05 #1
3 1337
sboyle55 wrote:
Hi...I'm a newbie to python, and very confused. I'm writing a simple
program and want the user to be able to edit a line that I display using
the full gnu readline capabilitites. (For example, control+a to go to the
beginning of the line.)

Then I want to be able to read the line after it's been edited...


Probably the built-in function raw_input already does what you want. It
uses readline if available.

--
Thomas

Aug 1 '05 #2
raw_input is an excellent suggestion, and almost exactly what I want.

But, I want to give the user a string to edit, not have them start from
scratch inputting a string.

Any other ideas?

Aug 2 '05 #3
sboyle55 wrote:
raw_input is an excellent suggestion, and almost exactly what I want.

But, I want to give the user a string to edit, not have them start from
scratch inputting a string.


<http://svn.thomas-lotze.de/PyASDF/pyasdf/cli.py>

Take a look at the fancy_input function.

--
Thomas

Aug 2 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jian Qiu | last post by:
Hi, I tried to install python2.4.2. Unfortunately building 'readline' extension failed. Here is what I got: (It is a bit long. If you are impatient, please look at the end where it reports the...
6
by: Christian Convey | last post by:
Hello, I've got a program that (ideally) perpetually monitors sys.stdin for lines of text. As soon as a line comes in, my program takes some action. The problem is, it seems like a very large...
0
by: spacelabstudio | last post by:
Hi, I'm observing some weird behavior and have written the following test program to demonstrate. This works under cygwin/WinXP but not Gentoo(kernel 2.6): huh.py...
4
by: David Bear | last post by:
I built python 2.4.2 for suse linux 9.3. I configured it to be a separate instance of python from the version packaged with suse. Now when I start it I get an error: python Python 2.4.2 (#4,...
1
by: David Hughes | last post by:
I used this function successfully with Python 2.4 to alter the encoding of a set of database records from latin-1 to utf-8, but the same program raises an exception using Python 2.5. This small...
2
by: Grant Edwards | last post by:
I'm trying to figure out how to use the gnu readline library so that when my program is prompting the user for input there is line editing and history support. I've read and re-read the...
0
by: Akira Kitada | last post by:
Hi list, I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed to build some of the modules. """ Failed to find the necessary bits to build these modules: _bsddb ...
0
by: M.-A. Lemburg | last post by:
On 2008-10-25 08:39, Akira Kitada wrote: Please post a bug report on python.org about these failures. The multiprocessing module is still fairly new and obviously needs more fine tuning for...
0
by: Akira Kitada | last post by:
Hi Marc-Andre, Thanks for the suggestion. I opened a ticket for this issue: http://bugs.python.org/issue4204 Now I understand the state of the multiprocessing module, but it's too bad to see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.