简体   繁体   English

缩写的Python命名约定

[英]Python naming convention for abbreviation

I want to get a variable naming in a consistent way 我想以一致的方式获取变量命名

I think cgi is an abbreviation,so it should be CGI 我认为cgi是缩写,所以应该是CGI

Should I change the set_camera_cgi to set_camera_CGI 我应该将set_camera_cgi更改为set_camera_CGI set_camera_CGI

But what if cgi_set_prefix to CGI_set_prefix , 但是,如果将cgi_set_prefix设置为CGI_set_prefix ,该怎么办CGI_set_prefix

Therefore the variable will start with a upcase, will it be more worse? 因此,变量将以大写字母开头,会更糟吗?

def set_camera_cgi(self, set_CGI_lst):
    try:
        cgi_set_prefix=''.join([
            "http://",
            self.conn_cfg["ip"],
            self.cgi["set"]])

        cgi_get_prefix=''.join([
            "http://",
            self.conn_cfg["ip"],
            self.cgi["get"]])

Name abbreviations using the usual lowercase convention (eg the cgi module, not the CGI module). 使用通常的小写字母约定来命名缩写(例如, cgi模块,而不是CGI模块)。 Basically, name everything according to PEP 8 when reasonable (even abbreviations). 基本上,在合理的情况下(甚至缩写),按照PEP 8命名所有内容。

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

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