[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: String compare question

Gary Herron

2/25/2008 4:50:00 PM

Robert Dailey wrote:
> Hi,
>
> Currently I have the following code:
>
>
> ignored_dirs = (
> r".\boost\include"
> )
You expect this is creating a tuple (or so I see from your "in" test in
the following code), but in fact the parenthesis do *not* make a tuple.
If you look at ignored_dirs, you'll find it's just a string. It's the
presence of commas that signam a tuple. You need

ignored_dirs = (
r".\boost\include", # It's that comma that makes this a tuple.
)
>
> if __name__ == "__main__":
> # Walk the directory tree rooted at 'source'
> for root, dirs, files in os.walk( source ):
> if root not in ignored_dirs:
> CopyFiles( root, files, ".dll" )
> else:
> print root
>
>
> Specifically take a look at the if condition checking if a string is
> inside of ignored_dirs. Of course this will only do substring
> searches, however I want to perform an exact match on this string. Is
> there anyway of doing this? Thanks.