Unbuffered keyboard input
apighin at my-deja.com
apighin at my-deja.com
Tue Nov 7 11:09:28 EST 2000
Searching through the archives, it looks like I can't do this. I guess
I will have to look at Curses.
To tell the truth, what I am really trying to do is to parse a file
that is ever expanding. The file will be open()ed, parsed, but will
continue to grow in the background. I can not seem to get Python to
see that the file have changed and begin processing again. Ideas?
In article <8u97c8$hod$1 at nnrp1.deja.com>,
apighin at my-deja.com wrote:
> Sorry, a bit of a newbie question here. I am just learning Python,
and
> am going through 'Learning Python' by O'Reilly. I am looking for a
way
> to open the keyboard/console as unbuffered. Here is their example:
>
> while 1:
> next = sys.stdin.read(1)
> if not next:
> break
> <process character 'next'>
>
> I have tried this, but the system input still seems to be buffered.
> Not until Enter is pressed does the processing of any of the input
> characters occur.
>
> What I would like to be able to do is do a stdin.read(1), and if no
> character is available, just go to the top of the loop and try again.
> I have looked at the Curses getkey() and getch(), but I don't really
> want Curses. Also, I have tried to open the /dev/console and /dev/kbd
> as unbuffered, but I get a 'Permission denied' error.
>
> Any help is appreciated.
>
> Anthony
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list