modules loaded by program (just iterate over the keys of sys modulesalso in the interpret hooks categoryan object' reference count is available via sys getrefcountand the names of modules built-in to the python executable are listed in sys builtin_module_names see python' library manual for detailsthese are mostly python internals informationbut such hooks can sometimes become important to programmers writing tools for other programmers to use exception details other attributes in the sys module allow us to fetch all the information related to the most recently raised python exception this is handy if we want to process exceptions in more generic fashion for instancethe sys exc_info function returns tuple with the latest exception' typevalueand traceback object in the all class-based exception model that python usesthe first two of these correspond to the most recently raised exception' classand the instance of it which was raisedtryraise indexerror exceptprint(sys exc_info()(indexerror()we might use such information to format our own error message to display in gui pop-up window or html web page (recall that by defaultuncaught exceptions terminate programs with python error displaythe first two items returned by this call have reasonable string displays when printed directlyand the third is traceback object that can be processed with the standard traceback moduleimport tracebacksys def grail( )raise typeerror('already got one'trygrail('arthur'exceptexc_info sys exc_info(print(exc_info[ ]print(exc_info[ ]traceback print_tb(exc_info[ ]already got one file ""line in file ""line in grail the traceback module can also format messages as strings and route them to specific file objectssee the python library manual for more details introducing the sys module