The OS interface and the command line

Generally, the operating system's shell starts applications with several pieces of information that constitute the OS API:

  • The shell provides each application with its collection of environment variables. In Python, these are accessed through os.environ.
  • The shell prepares three standard files. In Python, these are mapped to sys.stdin, sys.stdout, and sys.stderr. There are some other modules, such as fileinput, that can provide access to sys.stdin.
  • The command line is parsed by the shell into words. Parts of the command line are available in sys.argv. For POSIX operating systems, the shell may replace shell environment variables and glob wildcard filenames. In Windows, the simple cmd.exe shell will not ...

Get Mastering Object-Oriented Python - Second Edition 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.