472,958 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

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
2 2817
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Exits Funnel | last post by:
Hello, I'm a little confused about where I should include header files and was wondering whether there was some convention. Imagine I've written a class foo and put the definition in foo.h and...
0
by: Brian L. Troutwine | last post by:
I've recently developed a need for a python source code re-formatter, ideally conforming to the sort of style that pylint enforces. I don't know of any, and my googling wasn't very productive. Does...
4
by: Michael Yanowitz | last post by:
Hello: I ran the new pylint and my code and I had a few questions on why those are warnings or what I can do to fix them: 1) W: 0: Too many lines in module (1587) Why is 1587 considered too...
5
by: Tuomas | last post by:
#!/usr/bin/python """test pydev_0.9.3/../pylint""" __revision__ = "test_mod 0.1 by TV 06/10/22" lst = lst = map(lambda x: x.strip(), lst) result = """ No config file found, using default...
16
by: Alan Isaac | last post by:
I am brand new to pylint. As a tab user, I want the tabs warning turned off. How? Larger question: where is the config file format documented? Thanks, Alan Isaac
7
by: montyphyton | last post by:
Some recent posts about Python programming style got me thinking. Since we have the PEP 8 which gives some guidelines about the style to be used, do we have any program that can check for...
2
by: dmitrey | last post by:
Hi all, I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I cannot find how to use pylint from Eric IDE GUI. Does anyone know? Thank you in advance, D.
1
by: Stefan Rank | last post by:
on 31.07.2008 11:29 Diez B. Roggisch said the following: <snip> <snip> Three installations of pylint 0.14.0 that I have access to from here: pylint.bat 0.14.0, astng 0.17.2, common 0.27.0...
14
by: Astley Le Jasper | last post by:
I'm still learning python and would like to know what's a good way of organizing code. I am writing some scripts to scrape a number of different website that hold similar information and then...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.