Text of docs.python.org › 3.16 › library › python.html as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Python Runtime Services — Python 3.16.0a2 documentation

Navigation index modules | next | previous | Python » 3.16.0a2 documentation » The Python standard library » Python Runtime Services | Theme | 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: sys — System-specific parameters and functions sys.monitoring — Execution event monitoring Tool identifiers Registering and using tools Events Local events Deprecated event Ancillary events Other events The STOP_ITERATION event Turning events on and off Setting events globally Per code object events Disabling events Registering callback functions Callback function arguments sysconfig — Provide access to Python’s configuration information Configuration variables Installation paths User scheme posix_user nt_user osx_framework_user Home scheme posix_home Prefix scheme posix_prefix nt Installation path functions Other functions Command-line usage builtins — Built-in objects __main__ — Top-level code environment __name__ == '__main__' What is the “top-level code environment”?

Idiomatic Usage Packaging Considerations __main__.py in Python Packages Idiomatic Usage import __main__ warnings — Warning control Warning Categories The Warnings Filter Repeated Warning Suppression Criteria Describing Warning Filters Default Warning Filter Overriding the default filter Temporarily Suppressing Warnings Testing Warnings Updating Code For New Versions of Dependencies Available Functions Available Context Managers Concurrent safety of Context Managers dataclasses — Data Classes Module contents Post-init processing Class variables Init-only variables Frozen instances Inheritance Re-ordering of keyword-only parameters in __init__() Default factory functions Mutable default values Descriptor-typed fields contextlib — Utilities for with -statement contexts Utilities Examples and Recipes Supporting a variable number of context managers Catching exceptions from __enter__ methods Cleaning up in an __enter__ implementation Replacing any use of try-finally and flag variables Using a context manager as a function decorator Single use, reusable and reentrant context managers Reentrant context managers Reusable context managers abc — Abstract Base Classes atexit — Exit handlers atexit Example traceback — Print or retrieve a stack traceback Module-Level Functions TracebackException Objects StackSummary Objects FrameSummary Objects Examples of Using the Module-Level Functions Examples of Using TracebackException __future__ — Future statement definitions Module Contents gc — Garbage Collector interface inspect — Inspect live objects Types and members Retrieving source code Introspecting callables with the Signature object Classes and functions The interpreter stack Fetching attributes statically Current State of Generators, Coroutines, and Asynchronous Generators Code Objects Bit Flags Buffer flags Command-line interface annotationlib — Functionality for introspecting annotations Annotation semantics Classes Functions Recipes Using annotations in a metaclass Creating a custom callable annotate function Limitations of the STRING format Limitations of the FORWARDREF format Security implications of introspecting annotations site — Site-specific configuration hook Path extensions ( .pth files) Startup entry points ( .start files) Startup file examples Migrating from import lines in .pth files to .start files sitecustomize usercustomize Readline configuration Module contents Command-line interface See also See the concurrent.interpreters module, which similarly exposes core runtime functionality.

Previous topic zipapp — Manage executable Python zip archives Next topic sys — System-specific parameters and functions This page Report a bug Improve this page Show source « Navigation index modules | next | previous | Python » 3.16.0a2 documentation » The Python standard library » Python Runtime Services | Theme | © Copyright 2001 Python Software Foundation. This page is licensed under the Python Software Foundation License Version 2.

Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License. See History and License for more information. The Python Software Foundation is a non-profit corporation. Please donate. Last updated on Nov 19, 2026 (21:38 UTC). Found a bug ? Created using Sphinx 9.1.1.