Standard Input, Output, and Error
We'll cover the following
Command-line gurus are already familiar with the concept of standard input, standard output, and standard error. This section is for the rest of you.
Standard output and standard error (commonly abbreviated stdout
and stderr
) are pipes that are built into every UNIX-like system, including Mac OS X and Linux. When you call the print()
function, the thing you’re printing is sent to the stdout
pipe. When your program crashes and prints out a traceback, it goes to the stderr
pipe. By default, both of these pipes are just connected to the terminal window where you are working; when your program prints something, you see the output in your terminal window, and when a program crashes, you see the traceback in your terminal window too. In the graphical Python Shell, the stdout
and stderr
pipes default to your “Interactive Window”.
sys.stdin
,sys.stdout
,sys.stderr
.
Get hands-on with 1400+ tech skills courses.