February 2006
Intermediate to advanced
648 pages
14h 53m
English
The interpreter provides three standard file objects, known as standard input, standard output, and standard error, which are available in the sys module as sys.stdin, sys.stdout, and sys.stderr, respectively. stdin is a file object corresponding to the stream of input characters supplied to the interpreter. stdout is the file object that receives output produced by print.stderr is a file that receives error messages. More often than not, stdin is mapped to the user’s keyboard, whereas stdout and stderr produce text onscreen.
The methods described in the preceding section can be used to perform raw I/O with the user. For example, the following function reads a line of input from standard input:
def gets(): text ...