The *.pyi files are used by PyCharm and other development tools to provide
more information, such as PEP 484 type hints, than it is able to glean from
introspection of extension types and methods. They are not intended to be
imported, executed or used for any other purpose other than providing info
to the tools. If you don't use use a tool that makes use of .pyi files then
you can safely ignore this file.
Each Python module is represented by a .pyi "stub". This is a normal
Python file (i.e., it can be interpreted by Python 3), except all the
methods are empty.
显然,PyCharm创建.pyi文件的目的是:
此注释位于:
python27/Lib/site-packages/wx/core.pyi
我认为
.pyi
中的i
代表“接口”Java中接口的定义:
因为“接口”在Python中不存在(参见本文SO question between Abstract class and Interface),所以我认为设计人员打算专门为它提供一个特殊的扩展。
pyi
实现“存根”文件(来自Martin Fowler的定义)但是人们对接口比“存根”文件更熟悉,因此选择
.pyi
而不是.pys
更容易避免不必要的混淆。相关问题 更多 >
编程相关推荐