问题描述
PEP 8
尽管如此,相互矛盾:
import tkinter
from tkinter import *
这是文档错误吗?
推荐答案
我提出了错误在这一点上(Python核心开发人员已达成共识)是,尽管 * 确实违反了PEP 8,但这是一个合理的例外,因为 tkinter
提供了大量易于使用的名称(主要是诸如RIGHT或VERTICAL之类的常量)没有前缀。此外,PEP 8声明不要为了遵守此PEP而破坏向后兼容性!而且由于tkinter目前经常以这种方式导入,因此这种观点在这里适用。
I raised bug issue 32830 on this point and the consensus (reached by Python core developers) is that although the from tkinter import *
does violate PEP 8, this is a reasonable exception because tkinter
"provides the enormous number of names (mostly constants like RIGHT or VERTICAL) which are convenient to use without prefix." Additionally, PEP 8 states "do not break backwards compatibility just to comply with this PEP!" and since tkinter is frequently imported in this way currently, this sentiment applies here.
这篇关于Tkinter文档与PEP8相矛盾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!