29. Python Runtime Services
The modules described in this chapter provide a wide range of services related to the Python interpreter and its interaction with its environment. Here’s an overview:
- 29.1.
sys— System-specific parameters and functionsabiflagsargvbase_exec_prefixbase_prefixbyteorderbuiltin_module_namescall_tracing()copyright_clear_type_cache()_current_frames()_debugmallocstats()dllhandledisplayhook()dont_write_bytecodeexcepthook()__displayhook____excepthook__exc_info()exec_prefixexecutableexit()flagsfloat_infofloat_repr_stylegetallocatedblocks()getcheckinterval()getdefaultencoding()getdlopenflags()getfilesystemencoding()getfilesystemencodeerrors()get_int_max_str_digits()getrefcount()getrecursionlimit()getsizeof()getswitchinterval()_getframe()getprofile()gettrace()getwindowsversion()get_asyncgen_hooks()get_coroutine_wrapper()hash_infohexversionimplementationint_info__interactivehook__intern()is_finalizing()last_typelast_valuelast_tracebackmaxsizemaxunicodemeta_pathmodulespathpath_hookspath_importer_cacheplatformprefixps1ps2setcheckinterval()setdlopenflags()set_int_max_str_digits()setprofile()setrecursionlimit()setswitchinterval()settrace()set_asyncgen_hooks()set_coroutine_wrapper()_enablelegacywindowsfsencoding()stdinstdoutstderr__stdin____stdout____stderr__thread_infotracebacklimitversionapi_versionversion_infowarnoptionswinver_xoptions
- 29.2.
sysconfig— Provide access to Python’s configuration information - 29.3.
builtins— Built-in objects - 29.4.
__main__— Top-level script environment - 29.5.
warnings— Warning control - 29.6.
contextlib— Utilities forwith-statement contexts- 29.6.1. Utilities
- 29.6.2. Examples and Recipes
- 29.6.2.1. Supporting a variable number of context managers
- 29.6.2.2. Simplifying support for single optional context managers
- 29.6.2.3. Catching exceptions from
__enter__methods - 29.6.2.4. Cleaning up in an
__enter__implementation - 29.6.2.5. Replacing any use of
try-finallyand flag variables - 29.6.2.6. Using a context manager as a function decorator
- 29.6.3. Single use, reusable and reentrant context managers
- 29.7.
abc— Abstract Base Classes - 29.8.
atexit— Exit handlers - 29.9.
traceback— Print or retrieve a stack tracebackprint_tb()print_exception()print_exc()print_last()print_stack()extract_tb()extract_stack()format_list()format_exception_only()format_exception()format_exc()format_tb()format_stack()clear_frames()walk_stack()walk_tb()- 29.9.1.
TracebackExceptionObjectsTracebackExceptionTracebackException.__cause__TracebackException.__context__TracebackException.__suppress_context__TracebackException.stackTracebackException.exc_typeTracebackException.filenameTracebackException.linenoTracebackException.textTracebackException.offsetTracebackException.msgTracebackException.from_exception()TracebackException.format()TracebackException.format_exception_only()
- 29.9.2.
StackSummaryObjects - 29.9.3.
FrameSummaryObjects - 29.9.4. Traceback Examples
- 29.10.
__future__— Future statement definitions - 29.11.
gc— Garbage Collector interface - 29.12.
inspect— Inspect live objects- 29.12.1. Types and members
getmembers()getmodulename()ismodule()isclass()ismethod()isfunction()isgeneratorfunction()isgenerator()iscoroutinefunction()iscoroutine()isawaitable()isasyncgenfunction()isasyncgen()istraceback()isframe()iscode()isbuiltin()isroutine()isabstract()ismethoddescriptor()isdatadescriptor()isgetsetdescriptor()ismemberdescriptor()
- 29.12.2. Retrieving source code
- 29.12.3. Introspecting callables with the Signature object
- 29.12.4. Classes and functions
- 29.12.5. The interpreter stack
- 29.12.6. Fetching attributes statically
- 29.12.7. Current State of Generators and Coroutines
- 29.12.8. Code Objects Bit Flags
- 29.12.9. Command Line Interface
- 29.12.1. Types and members
- 29.13.
site— Site-specific configuration hook - 29.14.
fpectl— Floating point exception control
