Mick Charles Beaver wrote: > Hello, > > I've been looking into using PyLint on some of my programs, just as a > best practices kind of thing. > > Here's a snippet: > #====================================================================== > if __name__ == '__main__': > parser = optparse.OptionParser(usage='usage: %prog [OPTIONS]') > parser.add_option('-c', '--config', > action='store', > type='string', > dest='configFilename', > help='config file containing defaults') > (options, args) = parser.parse_args() > #====================================================================== > > Now, PyLint reports the following convention warnings: > C:158: Invalid name "parser" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$) > C:170: Invalid name "options" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$) > C:170: Invalid name "args" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$) > > Which style convention is it referring to? Should these really be all > caps?
There's a style convention that global constants at file scope are defined in all caps. Personally, I do all my optparsing in a special function rather than in the __name__ == '__main__' block. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list