Python 和骆驼一样吗
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PEP 8 包含所有答案。
PEP 8 contains all the answers.
最好与您的组织使用或熟悉的任何内容相匹配。如果其他人都已经使用了某种其他统一的方式,那么宣扬“一种真正的 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.
是的,有一个关于代码风格的 PEP,PEP 8。
检查“命名约定”
Yes there's a PEP on code style, PEP 8.
Check "Naming Conventions"