stdin
sys.stdin, sys.stdout, and sys.stderr are file objects corresponding to
the interpreter's standard input, output and error streams.
stdin is used for all interpreter input except for scripts
but including calls to input
and
rawinput. stdout is used for the output
of print and expression statements and for the prompts of [input]
and [rawinput]. The interpreter's own prompts and (almost all of)
its error messages go to
sys.stderr.
sys.stdout and
sys.stderr needn't be built-in file objects: any object is
acceptable as long as it has a write() method that takes a string
argument. (Changing these objects doesn't affect the standard I/O
streams of processes executed by os.popen, os.system or the exec*() family of functions
in the os module.)