The Scoop on Python Input?

Alan Gauld alan.gauld at bt.com
Wed Jun 20 08:18:21 EDT 2001


GulickDO at uReach.com wrote:
> disappointed how poorly the concept of "input" was covered in the
> books!  So maybe someone here can send me in the right direction.

The concept of "input" is that the program reads values from the
externaln environment.

Exactly how that is done depends a lot on what the external 
environment is.

> Is there a Python input function that will get just one character
> from the keyboard without waiting for enter to be pressed? 

There are several ways depending on the platform

thers the msvcrt module for windows or the curses one for unix.

> (like getch () in C++?)  

I don't think getch() is a standard C/C++ function.
getc() is but reads a character atva time from a stream
getchar() is just getc(stdin) and needs a return at the end.

getch() tends to be provided by compiler vendors for specific 
platforms and takes advantage of platform specifics to do its 
job. For the same readon Python can't realistically provide 
a portable getch() equivalent - what would it do for a user 
using a teleprinter? Or even a 3270 terminal?

Alan g



More information about the Python-list mailing list