sys.stdin.read() replacement

Benjamin Niemann b.niemann at betternet.de
Mon Aug 16 12:52:18 CEST 2004


Karin Lagesen wrote:

> 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.



More information about the Python-list mailing list