[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

Tim Chase

2/25/2008 5:27:00 PM

>> ignored_dirs = (
>> r".\boost\include", # It's that comma that makes this a tuple.
>> )
>>
>
> Thanks for reminding me of this. I always forget that!
>
> Now that it is correctly doing *only* whole string matches, what if I want
> to make it do a substring compare to each string in my ignored_dirs tuple?

Sounds like a good opportunity for the underused for/break/else
construct:

######################################################
ignored_dirs = (
r".\boost\include",
)

if __name__ == "__main__":
# Walk the directory tree rooted at 'source'
for root, dirs, files in os.walk( source ):
for dirname in ignored_dirs:
# may need to normalize to root.lower()
if dirname in root:
print 'Skipping', root
break
else:
CopyFiles( root, files, ".dll" )
######################################################

-tkc