In the preceding example, we used the command print to display the generated message in the terminal (or even in the Python shell). A priory input to the script is obtained via arguments and the variable sys.argv. The counterpart to print is the command input, which prompts for data from the terminal (or from the Python shell).
In Section 14.1: File handling, we saw how to provide a script with data and how to output data from a script by the use of file objects and related methods. The module sys makes it possible to treat the keyboard as a file object for input (for example, readline, readlines) and the console as a file object for output (for example, write, writelines).
The information flow is organized in UNIX by three streams:
- The standard input stream:Â STDINÂ Â
- The standard output stream:Â STDOUT
- The standard error stream:Â STDERR
These streams correspond to file objects that can be accessed in Python...