Chapter 9. Interacting with the Operating System
Whether a program helps a user balance a checkbook, play a game, write a letter, or connect to a website, all applications share one common feature — they all reside on top of an operating system. Be it Linux, Windows, or some other operating system, most applications (including Python scripts) must interface with the computer through its operating system. As with most scripting languages such as Perl or Ruby, Python has a vast collection of modules to enable the script programmer to interface with the operating system programmatically.
This chapter examines ways to communicate with the operating system through Python. Rather than a single, large application illustrating programming techniques, we will cover many topics with various snippets of code.
The commands and modules covered in this chapter are a small subset of what is available. For complete coverage of operating system services, see the Python Reference Manual.
The chapter covers three main topic areas:
Generic operating system services — Many features of an operating system are shared among the systems. For example, all operating systems have some way of listing files. Python's ability to access these generic operating system services makes programs more cross-platform.
Windows services — Python has many features to enable developers to access Windows services, such as the Windows Registry, the Windows Event Viewer, Windows services, and more. Techniques for accessing these ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access