sys.stdin.read() replacement

K

Karin Lagesen

I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?

Thanks,

Karin
 
P

P

Karin said:
I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?


import readline

(I don't know if it works on windos)

Pádraig.
 
B

Benjamin Niemann

Karin said:
I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?
The UNIX-ish way to do this, is invoking the user's prefered editor (as
defined by the VISUAL or EDITOR environment variables) on a temporary
file and read this file when the editor terminates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top