standard streams
The three streams every program starts with: standard input, standard output and standard error.
In more detail
sys.stdin is where input() reads, sys.stdout is where print() writes, and sys.stderr carries error messages and tracebacks separately from normal output. They are already open when the program starts and should not be closed. print(..., file=sys.stderr) sends text to standard error.
Example
import sys
print('done', file=sys.stderr)Related terms
- stream — Data that flows between a program and a source or destination piece by piece, rather than all at once.
- print() — The built-in function that writes values to the screen, separated by spaces and followed by a newline.
- sys module — The standard library module through which a program asks the running interpreter about itself.
Taught in
- Streams, Handles And Open Modes — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep