15. Generic Operating System Services¶
The modules described in this chapter provide interfaces to operating system features that are available on (almost) all operating systems, such as files and a clock. The interfaces are generally modeled after the Unix or C interfaces, but they are available on most other systems as well. Here’s an overview:
- 15.1.
os
— Miscellaneous operating system interfaces - 15.2.
io
— Core tools for working with streams - 15.3.
time
— Time access and conversions - 15.4.
optparse
— More powerful command line option parser- 15.4.1. Background
- 15.4.2. Tutorial
- 15.4.3. Reference Guide
- 15.4.3.1. Creating the parser
- 15.4.3.2. Populating the parser
- 15.4.3.3. Defining options
- 15.4.3.4. Option attributes
- 15.4.3.5. Standard option actions
- 15.4.3.6. Standard option types
- 15.4.3.7. Parsing arguments
- 15.4.3.8. Querying and manipulating your option parser
- 15.4.3.9. Conflicts between options
- 15.4.3.10. Cleanup
- 15.4.3.11. Other methods
- 15.4.4. Option Callbacks
- 15.4.4.1. Defining a callback option
- 15.4.4.2. How callbacks are called
- 15.4.4.3. Raising errors in a callback
- 15.4.4.4. Callback example 1: trivial callback
- 15.4.4.5. Callback example 2: check option order
- 15.4.4.6. Callback example 3: check option order (generalized)
- 15.4.4.7. Callback example 4: check arbitrary condition
- 15.4.4.8. Callback example 5: fixed arguments
- 15.4.4.9. Callback example 6: variable arguments
- 15.4.5. Extending
optparse
- 15.5.
getopt
— Parser for command line options - 15.6.
logging
— Logging facility for Python- 15.6.1. Logging tutorial
- 15.6.2. Logging Levels
- 15.6.3. Useful Handlers
- 15.6.4. Module-Level Functions
- 15.6.5. Logger Objects
- 15.6.6. Basic example
- 15.6.7. Logging to multiple destinations
- 15.6.8. Exceptions raised during logging
- 15.6.9. Adding contextual information to your logging output
- 15.6.10. Logging to a single file from multiple processes
- 15.6.11. Sending and receiving logging events across a network
- 15.6.12. Using arbitrary objects as messages
- 15.6.13. Optimization
- 15.6.14. Handler Objects
- 15.6.14.1. StreamHandler
- 15.6.14.2. FileHandler
- 15.6.14.3. WatchedFileHandler
- 15.6.14.4. RotatingFileHandler
- 15.6.14.5. TimedRotatingFileHandler
- 15.6.14.6. SocketHandler
- 15.6.14.7. DatagramHandler
- 15.6.14.8. SysLogHandler
- 15.6.14.9. NTEventLogHandler
- 15.6.14.10. SMTPHandler
- 15.6.14.11. MemoryHandler
- 15.6.14.12. HTTPHandler
- 15.6.15. Formatter Objects
- 15.6.16. Filter Objects
- 15.6.17. LogRecord Objects
- 15.6.18. LoggerAdapter Objects
- 15.6.19. Thread Safety
- 15.6.20. Configuration
- 15.6.21. More examples
- 15.7.
getpass
— Portable password input - 15.8.
curses
— Terminal handling for character-cell displays - 15.9.
curses.textpad
— Text input widget for curses programs - 15.10.
curses.wrapper
— Terminal handler for curses programs - 15.11.
curses.ascii
— Utilities for ASCII characters - 15.12.
curses.panel
— A panel stack extension for curses - 15.13.
platform
— Access to underlying platform’s identifying data - 15.14.
errno
— Standard errno system symbols - 15.15.
ctypes
— A foreign function library for Python- 15.15.1. ctypes tutorial
- 15.15.1.1. Loading dynamic link libraries
- 15.15.1.2. Accessing functions from loaded dlls
- 15.15.1.3. Calling functions
- 15.15.1.4. Fundamental data types
- 15.15.1.5. Calling functions, continued
- 15.15.1.6. Calling functions with your own custom data types
- 15.15.1.7. Specifying the required argument types (function prototypes)
- 15.15.1.8. Return types
- 15.15.1.9. Passing pointers (or: passing parameters by reference)
- 15.15.1.10. Structures and unions
- 15.15.1.11. Structure/union alignment and byte order
- 15.15.1.12. Bit fields in structures and unions
- 15.15.1.13. Arrays
- 15.15.1.14. Pointers
- 15.15.1.15. Type conversions
- 15.15.1.16. Incomplete Types
- 15.15.1.17. Callback functions
- 15.15.1.18. Accessing values exported from dlls
- 15.15.1.19. Surprises
- 15.15.1.20. Variable-sized data types
- 15.15.2. ctypes reference
- 15.15.1. ctypes tutorial