O'Reilly logo

Python Pocket Reference, Second Edition by Mark Lutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The sys Interpreter 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). New in 2.0.

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(func)

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

_ _displayhook_ _

Original value of displayhook (for restores).

excepthook(type, value, traceback)

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

_ _excepthook_ _

Original value of excepthook (for restores).

exc_info( )

Returns tuple of three values describing the exception currently being handled: (type, value, traceback). Specific to current thread. Subsumes exc_type, exc_value, and exc_traceback in Python 1.5 and later.

exc_type

Type of exception being handled (when an exception has been raised). Not thread-specific.

exc_value

Exception’s parameter (second argument to raise). Not thread-specific.

exc_traceback

Exception’s traceback object. Not thread-specific. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required