内容表

  • pyclbr — Python 模块浏览支持
    • 函数对象
    • 类对象

上一话题

tabnanny — 歧义缩进的检测

下一话题
就业培训     下载中心     Wiki     联络
登录   注册

Log
  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. Python 语言服务
  9. pyclbr — Python 模块浏览支持

pyclbr — Python 模块浏览支持 ¶

源代码: Lib/pyclbr.py


The pyclbr 模块提供 python 编码模块定义的有关函数、类及方法的有限信息。这些信息足以实现模块浏览器。信息是从 Python 源代码提取的,而不是通过导入模块,因此本模块可以安全地用于不可信代码。此限定使之不可能将本模块用于未在 Python 中实现的模块,包括所有标准和可选扩展模块。

pyclbr. readmodule ( 模块 , path = None ) ¶

Return a dictionary mapping module-level class names to class descriptors. If possible, descriptors for imported base classes are included. Parameter 模块 is a string with the name of the module to read; it may be the name of a module within a package. If given, path is a sequence of directory paths prepended to sys.path , which is used to locate the module source code.

This function is the original interface and is only kept for back compatibility. It returns a filtered version of the following.

pyclbr. readmodule_ex ( 模块 , path = None ) ¶

Return a dictionary-based tree containing a function or class descriptors for each function and class defined in the module with a def or class statement. The returned dictionary maps module-level function and class names to their descriptors. Nested objects are entered into the children dictionary of their parent. As with readmodule, 模块 names the module to be read and path is prepended to sys.path. If the module being read is a package, the returned dictionary has a key '__path__' whose value is a list containing the package search path.

Added in version 3.7: Descriptors for nested definitions. They are accessed through the new children attribute. Each has a new parent attribute.

The descriptors returned by these functions are instances of Function and Class classes. Users are not expected to create instances of these classes.

函数对象 ¶

class pyclbr. Function ¶

类 Function instances describe functions defined by def statements. They have the following attributes:

file ¶

Name of the file in which the function is defined.

模块 ¶

描述函数定义的模块名称。

name ¶

函数的名称。

lineno ¶

The line number in the file where the definition starts.

parent ¶

For top-level functions, None . For nested functions, the parent.

Added in version 3.7.

children ¶

A dictionary mapping names to descriptors for nested functions and classes.

Added in version 3.7.

is_async ¶

True 对于定义函数具有 async 前缀, False 否则。

Added in version 3.10.

类对象 ¶

class pyclbr. 类 ¶

类 Class instances describe classes defined by class statements. They have the same attributes as Functions and two more.

file ¶

Name of the file in which the class is defined.

模块 ¶

描述类定义的模块名称。

name ¶

The name of the class.

lineno ¶

The line number in the file where the definition starts.

parent ¶

For top-level classes, None . For nested classes, the parent.

Added in version 3.7.

children ¶

A dictionary mapping names to descriptors for nested functions and classes.

Added in version 3.7.

super ¶

列表化的 Class objects which describe the immediate base classes of the class being described. Classes which are named as superclasses but which are not discoverable by readmodule_ex() are listed as a string with the class name instead of as Class 对象。

方法 ¶

A dictionary mapping method names to line numbers. This can be derived from the newer children dictionary, but remains for back-compatibility.

内容表

  • pyclbr — Python 模块浏览支持
    • 函数对象
    • 类对象

上一话题

tabnanny — 歧义缩进的检测

下一话题

py_compile — 编译 Python 源文件

本页

  • 报告 Bug
  • 展示源

快速搜索

键入搜索术语或模块、类、函数名称。

  1. 首页
  2. Python 3.12.4
  3. 索引
  4. 模块
  5. 下一
  6. 上一
  7. Python 标准库
  8. Python 语言服务
  9. pyclbr — Python 模块浏览支持

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1