473,387 Members | 1,516 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,387 software developers and data experts.

Add readline capability to existing interactive program

Hello,

I use an interactive simulator/data plotter called ocean. I get really
frustrated using it because it does not have basic readline
capabilities like ctrl-a for beginning of line and ctrl-k to kill the
rest of the line.

I was thinking this might be easy to add with Python. Do something
like start python and then kick off the ocean job and then use
something like pexpect to interact with it. I think this would work
but there may be an even easier way to do it, maybe directly with
popen2.

A quick google search lead me to:

http://aspn.activestate.com/ASPN/Coo.../Recipe/108287

and shows code:

import os
f=os.popen('gnuplot', 'w')
print >>f, "set yrange[-300:+300]"
for n in range(300):
print >>f, "plot %i*cos(x)+%i*log(x+10)" % (n,150-n)
f.flush()
this kind of works but not quite. Windows don't pop open and results
of calculations (3+3) don't echo back.

Before I started coding, I thought I would ask if a module or examples
already exits that do what I want.

jr

Mar 14 '07 #1
1 1174

Jacob Rael wrote:
Hello,

I use an interactive simulator/data plotter called ocean. I get really
frustrated using it because it does not have basic readline
capabilities like ctrl-a for beginning of line and ctrl-k to kill the
rest of the line.
I guess the easiest way would be this: http://freshmeat.net/projects/rlwrap/.
If you use Microsoft Windows, a cygwin version is available too,
apparently.
<snipped>
--
Kushal Kumaran

Mar 15 '07 #2

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

Similar topics

1
by: Jonathan Daugherty | last post by:
Hello all, I've read some posts here talking about the fact that the 'readline' module packaged with python is only good for augmenting the behavior of the interactive interpreter. Can anyone...
12
by: Mike Maxwell | last post by:
When I invoke readline() in a for loop, why does it return a series of one-char strings, rather than the full line? >>> for sL in sys.stdin.readline(): print sL .... abc a b c
0
by: Brano Zarnovican | last post by:
Hi ! I'd like to init curses and still have working Python interactive command line. I found that you can replace stdin/stdout/stderr like this: #!/usr/bin/python -i import curses import...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.