Python 和骆驼一样吗

发布于 2024-09-16 20:59:35 字数 209 浏览 7 评论 0原文

Java 风格的驼峰命名法是 Python 中的良好实践吗?我知道大写名称应该按照类名称的约定保留。根据良好的风格,方法应该是小写字母,或者实际上我不太确定。有关于命名的 PEP 吗?

评论:

对不起骆驼:),我从答案PEP8中了解到,我的标题实际上正确地称为mixedCase(大写版本是CamelCase)阅读PEP后,我知道带下划线的正常小写函数命名也应该用于方法。

Are Java style camelCase names good practice in Python. I know Capilized names should be reserved by convention for Class names. Methods should be small letters according to good style, or actually I am not so sure. Is there PEP about naming?

COMMENTS:

Sorry for camels :) , I learned from answer PEP8, that my title is actually properly called mixedCase (Capitalized version is the CamelCase) After reading the PEP, I know that normal small case function naming with underscores should be used for methods also.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

︶葆Ⅱㄣ 2024-09-23 20:59:35

PEP 8 包含所有答案。

PEP 8 contains all the answers.

一个人的旅程 2024-09-23 20:59:35

最好与您的组织使用或熟悉的任何内容相匹配。如果其他人都已经使用了某种其他统一的方式,那么宣扬“一种真正的 Python 风格”并不能完全建立和谐。如果它是一些风格的随机大杂烩,那么就继续提倡某种统一。

It's best to match whatever your organization uses or is comfortable with. Preaching "the One True Python style" doesn't exactly build harmony if everyone else already uses some other uniform manner. If it's some random hodgepodge of styles, then go ahead and advocate for some unification.

一枫情书 2024-09-23 20:59:35

是的,有一个关于代码风格的 PEP,PEP 8。

检查“命名约定”

Yes there's a PEP on code style, PEP 8.

Check "Naming Conventions"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文