Python Runtime ServicesPython运行时服务¶
The modules described in this chapter provide a wide range of services related to the Python interpreter and its interaction with its environment. 本章描述的模块提供了与Python解释器及其与环境交互相关的广泛服务。Here’s an overview:以下是概述:
sys
—System-specific parameters and functions系统特定参数和功能sysconfig
—Provide access to Python’s configuration information提供对Python配置信息的访问builtins
—Built-in objects内置对象__main__
—Top-level code environment顶层代码环境warnings
—Warning control警告控件dataclasses
—Data Classes数据类contextlib
—Utilities forwith
-statement contextswith
语句上下文的实用程序Utilities公用事业Examples and Recipes示例和配方Supporting a variable number of context managers支持数量可变的上下文管理器Catching exceptions from正在捕获来自__enter__
methods__enter__
方法的异常Cleaning up in an在__enter__
implementation__enter__
实现中清理Replacing any use of替换try-finally
and flag variablestry-finally
和flag变量的任何用法Using a context manager as a function decorator使用上下文管理器作为函数装饰器
Single use, reusable and reentrant context managers一次性、可重用和可重入的上下文管理器
abc
—Abstract Base Classes抽象基类atexit
—Exit handlers退出处理程序traceback
—Print or retrieve a stack traceback打印或检索堆栈回溯__future__
—Future statement definitions未来报表定义gc
—Garbage Collector interface垃圾收集器接口inspect
—Inspect live objects检查活动对象Types and members类型和成员Retrieving source code正在检索源代码Introspecting callables with the Signature object使用Signature
对象内省可调用项Classes and functions类别和功能The interpreter stack解释器堆栈Fetching attributes statically静态获取属性Current State of Generators and Coroutines发电机和协同程序的当前状态Code Objects Bit Flags代码对象位标志Command Line Interface命令行界面
site
—Site-specific configuration hook特定于站点的配置挂钩