根据 PEP 8 在 Python 中哪里使用驼峰命名法?
最近我开始使用 Python 进行机器学习,但是我对这种语言还很陌生。我知道“可读性很重要”,所以我有一直在努力让自己熟悉 PEP 8 编码约定。我知道在哪里使用 joined_lower
、StudlyCaps
和 ALL_CAPS
命名约定,但是我不太明白在哪些情况下可以使用 camelCase
。
根据 PEP 8 指南:
只有在已经是混合大小写的上下文中才允许使用混合大小写 流行的风格(例如threading.py),保留向后 兼容性。
但这个声明对我来说并没有什么意义。 “流行风格”是什么意思?需要这种向后兼容性的适用情况是什么?
我在网络上找不到使用命名样式来符合预先存在的约定的单个示例。
Recently I have started working on machine learning with Python, however I'm very new to this language. I know that "Readability counts", so I have been trying to get myself familiar with the
PEP 8 coding conventions. I know where to usejoined_lower
, StudlyCaps
and ALL_CAPS
naming conventions, however I didn't quite get in which situations I can use the camelCase
.
According to the PEP 8 guide:
mixedCase is allowed only in contexts where that’s already the
prevailing style (e.g. threading.py), to retain backwards
compatibility.
but this statement isn't saying much to me. What does it mean by "prevailing style"? What could be an applicable case that would require this backward compatibility?
I couldn't find a single example on the web that used naming style to conform to pre-existing conventions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论