Python: "re" 模块包含在 "Tkinter" 模块中?

Python: "re" module is included in "Tkinter" module?

我在 MacOS[=31= 上使用 Python 3.6.4Miniconda ].我很好奇我可以在导入 tkinter 后使用属于 re 模块的方法。例如,如果我想使用 re 方法而不导入它:

>>> re.compile('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 're' is not defined

但是如果我在导入 tkinter 后使用 re 方法,它会正常工作,例如:

>>> from tkinter import *
>>> re.compile('abc')
re.compile('abc')

所以我可以使用 re.compile(),即使我没有用过 import re。为什么会这样?

来自第 39 行的 the tkinter Source

import re

因此,当您导入模块 tkinter 时,您会自动将其导入 re