1

I want to get a variable naming in a consistent way

I think cgi is an abbreviation,so it should be CGI

Should I change the set_camera_cgi to set_camera_CGI

But what if cgi_set_prefix to 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"]])
newBike
  • 14,385
  • 29
  • 109
  • 192

1 Answers1

1

Name abbreviations using the usual lowercase convention (e.g. the cgi module, not the CGI module). Basically, name everything according to PEP 8 when reasonable (even abbreviations).

nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • But he suggested capitalize all the letters of the abbreviation , so I'm kind of confused http://stackoverflow.com/questions/2853531/how-do-you-pep-8-name-a-class-whose-name-is-an-acronym – newBike Feb 27 '14 at 05:26
  • Only `When using abbreviations in CapWords`. So, you would always write `nasa_jpl` in a function or variable name. – nneonneo Feb 27 '14 at 05:35
  • so even in module name(filename), I should use cgi_automation.py , not the CGI_automation.py , it's a more common convention , right ? Only use `Class CGIAutomation ` in camel case, that is class name, right ? – newBike Feb 27 '14 at 05:37
  • Yep. You should use the lowercase for naming the files. And yep to the class name, too. – nneonneo Feb 27 '14 at 05:41