Name

stdin, stdout, stderr

Synopsis

stdin , stdout, and stderr are predefined file objects that correspond to Python’s standard input, output, and error streams. You can rebind stdout and stderr to file-like objects (objects that supply a write method accepting a string argument) to redirect the destination of output and error messages. You can rebind stdin to a file-like object open for reading (one that supplies a readline method returning a string) to redirect the source from which built-in functions raw_input and input read. The original values are available as __stdin__, __stdout__, and __stderr__. Chapter 10 covers file objects and streams.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.