模块在Python中有类型吗?

我正在读
PEP338.有些话困惑我:

If the module is found, and is of type PY_SOURCE or PY_COMPILED , then the command line is effectively reinterpreted from python <options> -m <module> <args> to python <options> <filename> <args> .

模块在Python中有类型吗?

最佳答案 模块可以从不同的来源加载.作者参考了加载模块的2个特定来源,参见
imp module documentation

imp.PY_SOURCE
The module was found as a source file.

[…]

imp.PY_COMPILED
The module was found as a compiled code object file.

[…]

imp.C_EXTENSION
The module was found as dynamically loadable shared library.

这些值用于imp.get_suffixes() function的返回值等.

PEP声明只支持从源(.py文件)和字节码缓存文件(.pyc)加载的模块; -m开关不支持C扩展模块(通常是.so或.dll动态加载的库).

生成的模块对象仍然只是一个模块对象;您找到的文本中的单词类型不是指Python的类型系统.

    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞