Re: How do read a single character from stdin?

Guido.van.Rossum@cwi.nl
Wed, 09 Mar 1994 22:36:45 +0100

> I am embarrased asking a question like this amongst all this
> discussion of lambda bindings, but how do you read a single character
> from stdin?

Don't be embarrassed -- at least this one is easy to answer :-)

You can read n characters from any open file using fp.read(n). You
can read until EOF using fp.read(). (Here fp is the file pointer --
read is a method. Check the library manual for more file methods.)

Standard input is sys.stdin. Check the library manual for module sys.

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>