Unbuffered keyboard input

apighin at my-deja.com apighin at my-deja.com
Tue Nov 7 19:08:38 CET 2000

Hey, this is great.  I was trying to emulate 'tail -f', so the example
you gave was bang on.  And the second response with the pointer to the
FAQ (oops!) is great too!  Thanks.  I did a quick 'truss tail -f' to
see what it was doing, so I stumbled on the seek(0,1), which seems to
work pretty good so far.

In article <8u994q$42v$1 at slb6.atl.mindspring.net>,
  "Andrew Dalke" <dalke at acm.org> wrote:
> apighin at my-deja.com wrote:
> >I am looking for a way to open the keyboard/console as unbuffered.
> Use the '-u' flag to start Python in unbuffered mode.
> >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.
> Or read the FAQ entry titled "How to get a single keypress at a time?"
> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.074.htp
> (Your mention of /dev/console implies this Unix answer.  There's a
> to another solution for MS Windows.)
>                     Andrew
>                     dalke at acm.org

Sent via Deja.com http://www.deja.com/
Before you buy.

More information about the Python-list mailing list