简体   繁体   English

Python 变量命名约定

[英]Python variable naming convention

What is meaning of this rule?这条规则的含义是什么? 1.mixedCase is allowed only in contexts where that's already the prevailing style (eg threading.py), to retain backwards compatibility. 1.mixedCase 仅在已经是主流样式的上下文中允许使用(例如 threading.py),以保持向后兼容性。

mixedCase is allowed only in contexts where that's already the prevailing style (eg threading.py), to retain backwards compatibility混合大小写仅在已经是流行样式的上下文中被允许(例如 threading.py),以保持向后兼容性

It means exactly what is says.它的意思正是所说的。 Function names should only be mixed case - like doThing or computeAmount if that style is already in use in the containing module, of which threading.py is an example. Function 名称只能大小写混合 - 像doThingcomputeAmount如果该样式已在包含模块中使用,其中threading.py就是一个示例。

This is to cater for modules which were written before PEP8.这是为了迎合在 PEP8 之前编写的模块。

In any modern Python code you should use snake_case for function and variable names.在任何现代 Python 代码中,您应该使用snake_case来表示 function 和变量名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM