The sys Module

The sys module contains interpreter-related exports. It also provides access to some environment components, such as the command line, standard streams, and so on.

argv

Command-line argument strings list: [command, arguments...]. Like C’s argv array.

byteorder

Indicates the native byte-order (e.g., big for big-endian).

builtin_module_names

Tuple of string names of C modules compiled into this Python interpreter.

copyright

String containing the Python interpreter copyright.

dllhandle

Python DLL integer handle; Windows only (see the Python Library Reference).

displayhook(value)

Called by Python to display result values in interactive sessions; assign sys.displayhook to a one-argument function to customize output.

excepthook(type, value, traceback)

Called by Python to display uncaught exception details to stderr; assign sys.excepthook to a three-argument function to customize exception displays.

exc_info()

Returns tuple of three values describing the exception currently being handled (type, value, traceback), where type is the exception class, value is the instance of the exception class raised, and traceback is an object that gives access to the runtime call stack as it existed when the exception occurred. Specific to current thread. Subsumes exc_type, exc_value, and exc_traceback in Python 1.5 and later (all three of which are removed completely in Python 3.0). See the traceback module in the Python Library Reference for processing traceback objects, and The try Statement for more ...

Get Python Pocket Reference, 4th 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.