467,888 Members | 1,360 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,888 developers. It's quick & easy.

pylint style convention

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?

Thank you,
Mick

Jul 23 '07 #1
  • viewed: 2640
Share:
2 Replies
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
Jul 24 '07 #2
mi**@cs.wisc.edu (Mick Charles Beaver) writes:
Here's a snippet:
pylint is reporting line numbers. Can you show us line numbers for
this 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_]*)|(__.*__))$)
These warnings are for line 158 and line 170, which covers a range of
13 lines. Your code snippet is only 8 lines long. So at least one of
those two lines that have warnings reported are not in the code you've
shown to us.

--
\ "Too many Indians spoil the golden egg." -- Sir Joh |
`\ Bjelke-Petersen |
_o__) |
Ben Finney
Jul 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Exits Funnel | last post: by
reply views Thread by Brian L. Troutwine | last post: by
4 posts views Thread by Michael Yanowitz | last post: by
5 posts views Thread by Tuomas | last post: by
16 posts views Thread by Alan Isaac | last post: by
7 posts views Thread by montyphyton | last post: by
2 posts views Thread by dmitrey | last post: by
1 post views Thread by Stefan Rank | last post: by
14 posts views Thread by Astley Le Jasper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.