如果内部的模块名称和类名称具有相同的名称,那么Python中是否存在风险?(Are there any risks in Python if the module name and class nam

编程入门 行业动态 更新时间:2024-10-28 20:27:55
如果内部的模块名称和类名称具有相同的名称,那么Python中是否存在风险?(Are there any risks in Python if the module name and class name from inside had identical names?)

我想知道是否有任何风险在模块内使用完全相同的名称作为模块和类。

I would like to know if there any risks to use the exact same name for module and a class from inside the module.

最满意答案

PEP 8说模块应该有简短的全小写名称,而类名称使用CapWords约定。 所以,如果你对一个模块和一个类有相同的名字,你不会遵循这些风格约定。

从技术上讲,没有风险。

The PEP 8 says that modules should have short, all-lowercase names, while class names use the CapWords convention. So, if you have the same name for a module and a class, you're not following those style conventions.

Technically, there's no risk at all.

更多推荐

本文发布于:2023-07-24 13:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1246275.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   是否存在   模块   风险   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!