[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: Request for tips on my first python script.
From:       Roberto Bonvallet <Roberto.Bonvallet () cern ! ch>
Date:       2006-09-08 15:36:18
Message-ID: eds2li$7b7$1 () sunnews ! cern ! ch
[Download RAW message or body]

Lex Hider wrote:
> Any tips on the code quality and use of python would be appreciated. I've
> got a feeling the overall structure is up the creek.
[...]
>    for opt, arg in opts:
>        if opt in ("-l", "--latest"):
>            latest = int(arg)
>        elif opt in ("--notfound"):
>            ignoreNotFound = True #add notfound files to log 

Subtle bug here:  ("--notfound") is not a tuple, is just a string, so what
you are actually testing is whether opt is a substring of "--not-found".
To actually build a 1-element tuple, you have to put a trailing comma:

    elif opt in ("--notfound", ):

but it would be clearer if you just use:

    elif opt == "--notfound":

-- 
Roberto Bonvallet
-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic