为什么“收款ABC”模块中有可调用ABC?

2024-04-28 01:23:31 发布

您现在位置:Python中文网/ 问答频道 /正文

Python ^{}模块包含许多方便的abc,用于检查对象的各种特性,但是其中一个似乎不属于的abc是Callable。没有标准集合是可调用的,而且^{}没有提供任何推理,甚至没有提到可调用的ABC,那么为什么它在这个包中而不是在其他地方?在

上下文: 为了好玩,我正在编写一个Python->;Java编译器,我只想看看这个决定背后是否有任何推理,以便在代码中列出这种推理。在


Tags: 模块对象代码gt标准编译器地方特性
1条回答
网友
1楼 · 发布于 2024-04-28 01:23:31

本模块源于PEP-3119,提出:

Specific ABCs for containers and iterators, to be added to the collections module.

但从那以后,它就演变成了更多的东西。现在模块描述没有明确提到容器和迭代器。上面写着:

This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whether it is a mapping.

我相信它是collections子模块,因为它在过去是它的一部分:

New in version 3.3: Formerly, this module was part of the collections module.

相关问题 更多 >