Tkinter文档与PEP8相矛盾

2024-03-28 13:00:56 发布

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

政治公众人物8states

Wildcard imports (from import *) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools.

然而official documentation是矛盾的:

to use Tkinter all you need is a simple import statement:

import tkinter

Or, more often:

^{pr2}$

这是“文档错误”吗?在


Tags: fromimportmakeasitbe政治imports
1条回答
网友
1楼 · 发布于 2024-03-28 13:00:56

我在这一点上提出了错误issue 32830,并且一致认为(Python核心开发人员达成的共识)虽然from tkinter import *确实违反了pep8,但这是一个合理的例外,因为tkinter“提供了大量的名称(主要是像RIGHT或VERTICAL这样的常量),这些名称不需要前缀就可以使用。”此外,pep8状态“没有打破向后兼容性只是为了遵守这个政治公众人物!”由于目前tkinter经常以这种方式进口,这种观点在这里也适用。在

相关问题 更多 >