__init__.py
文件作用
IDLE的源代码作为一个package(库),显然,它需要一个__init__.py文件来进行标识。若要把一个文件夹变为package,这个文件夹里必须有一个名为__init__的文件。当导入这个package时,__init__.py会被同时执行。
idlelib(IDLE源码库)的__init__.py文件非常简单,仅仅是包括了一些我们不会在意的注释以及一个名为testing的变量。该变量的取值为True或False,用来标记我们是否要对IDLE进行测试。一般情况下,其值为False。
文件源码
"""The idlelib package implements the Idle application.
Idle includes an interactive shell and editor.
Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later.
Use the files named idle.* to start Idle.
The other files are private implementations. Their details are subject to
change. See PEP 434 for more. Import them at your own risk.
"""
testing = False # Set True by test.test_idle.
文件分析
恐怕不需要了?
__main__.py
文件作用
除了__init__.py,在一个package中还会有__main__.py。这个文件的作用是作为package的“