sys.stdin.read() replacement

Benjamin Niemann b.niemann at betternet.de
Mon Aug 16 14:10:29 CEST 2004


not sure, if importing readline really gets the desired result (if I 
understand the initial question correctly)

suppose the following input:
   > this is ym first line
   > and another line
   (oops there's a typo in the first line, user hits cursor up two 
times, and corrects it)
   > this is my first line
   ...

what the program will then reads is:
   "this is ym first line"
   "and another line"
   "this is my first line"
   ...
with no chance to see that the third line is supposed to replace line one.
Or is readline actually more powerful than I remember?


> import readline will work on Windows:
> a) if you're running the cygwin python, inside cygwin
> b) if you've installed a readline module; there are at least two available.
> Excuse me for the self-referential answer, but about half and hour before I
> read this, I wrote a blog entry all about readline modules, with links to
> and comments about the Windows ones.  The permalink is
> http://www.livejournal.com/users/benlast/16766.html or it's the most recent
> entry at http://www.livejournal.com/users/benlast/
> 
> Karin: if you do import a readline, you can then use sys.stdin.readline() to
> read a line of input, and you should get some sort of history functionality
> (up-arrow, for example, will recall a previous line).
> 
> regards
> b
> 
> 
>>-----Original Message-----
>>From: python-list-bounces+ben=benlast.com at python.org
>>[mailto:python-list-bounces+ben=benlast.com at python.org]On Behalf Of
>>P at draigBrady.com
>>Sent: 16 August 2004 11:52
>>To: python-list at python.org
>>Subject: Re: sys.stdin.read() replacement
>>
>>
>>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?
>>
>>
>>import readline
>>
>>(I don't know if it works on windos)
>>
>>Pádraig.
>>--
>>http://mail.python.org/mailman/listinfo/python-list
> 
> 



More information about the Python-list mailing list