String compare question
Gary Herron
gherron at islandtraining.com
Mon Feb 25 11:49:48 EST 2008
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.
More information about the Python-list
mailing list