The attributes of the
sys module are bound to data and functions that provide information on the state of the Python interpreter or affect the interpreter directly. This section documents the most frequently used attributes of
sys, in alphabetical order.
The list of command-line arguments passed to the main script.
argv is the name or full path of the main script, or
'-c' if the -c option was used. See The optparse Module for a good way to use
In interactive sessions, the Python interpreter calls
displayhook, passing it the result of each expression statement entered. The default
displayhook does nothing if
None; otherwise, it preserves and displays
if value is not None:
_ _builtin_ _._ = value
You can rebind
sys.displayhook in order to change interactive behavior. The original value is available as
sys._ _displayhook_ _.
When an exception is not caught by any handler, and thus propagates all the way up the call stack, Python calls
excepthook, passing it the exception class, exception object, and traceback object, as covered in Exception Propagation. The default
excepthook displays the error and traceback. You can rebind
sys.excepthook to change what is displayed for uncaught exceptions (just before Python returns to the interactive loop or terminates). The original value is available as
sys._ _excepthook_ _.
If the current thread ...