Wait for a keypress before continuing?

Seebs usenet-nospam at seebs.net
Wed Aug 17 12:33:06 EDT 2011

On 2011-08-17, peter <peter.mosley at talk21.com> wrote:
> Is there an equivalent to msvcrt for Linux users?  I haven't found
> one, and have resorted to some very clumsy code which turns off
> keyboard excho then reads stdin. Seems such an obvious thing to want
> to do I am surprised there is not a standard library module for it. Or
> have I missed someting (wouldn't be the first time!)

There's no direct equivalent to the whole of msvcrt.  The Unixy way to
do stuff like that on the command line is usually curses.  But to make
a long story short:  Unix evolved in a setting where there was often
not a user at *THE* console, and users were often on devices such that
it made sense to have all the line editing happen on the remote end, with
the remote end sending a completed line once the user was done with all
that stuff like backspaces.

Unix programs that do stuff like this for tty input do exist, of course,
but for the most part, they use an entire API designed for creating such
utilities, rather than one or two specialized functions.  (Another part
of the reason for this:  The Unix solution scales nicely to the case where
the five people using your program will be doing so on physically
different hardware terminals which don't use the same escape sequences
for cursor movement.)

Usually when people omit something obvious from a design, it's because of
other constraints or history to the design which make it less obvious.

Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.

More information about the Python-list mailing list