pylint style convention

Matt McCredie mccredie at
Tue Jul 24 02:39:34 CEST 2007

> Which style convention is it referring to? Should these really be all
> caps?

I think pylint is expecting that any variables declared outside of a
function should be constants with special meanings (similar to #define or
enum values in c). So, I guess to get rid of that message you should do
something like this:

def main(args=None):
    if args is None:
        args = sys.argv

    parser = optparse.OptionParser(usage='usage: %prog [OPTIONS]')
    parser.add_option('-c', '--config',
                      help='config file containing defaults')
    (options, args) = parser.parse_args(args)

if "__main__" == __name__:

Here is an article by GvR that goes over main functions in python: You didn't really
ask for it, but I think it is good reading. His examples all use getopt
though, instead of optparse. I have come up with my own (probably overkill
for 99% of python scripts) template that uses optparse. If you really want
to see it let me know and I will send it to you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list