Book Image

Mastering Object-oriented Python

By : Steven F. Lott, Steven F. Lott
Book Image

Mastering Object-oriented Python

By: Steven F. Lott, Steven F. Lott

Overview of this book

Table of Contents (26 chapters)
Mastering Object-oriented Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Some Preliminaries
Index

The OS interface and the command line


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

  • The shell provides each application 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. Python will provide some of the original command line; we'll look at the details in the following sections. For POSIX operating systems, the shell may replace shell environment variables and glob wildcard filenames. In Windows, the simple cmd.exe shell will not glob filenames for us.

  • The OS also maintains context settings such as the current working directory, user ID, and group. These are available through the os module. They aren...