path stuff

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri May 11 23:58:24 EDT 2007


En Fri, 11 May 2007 13:25:55 -0300, fscked <fsckedagain at gmail.com>  
escribió:

>> import os, sys, os.path, fnmatch
>>
>> def findinterestingfiles(root_dir):
>>    for dirpath, dirnames, filenames in os.walk(root_dir):
>>      if "Archived" in dirnames:
>>        dirnames.remove("Archived")
>>      for filename in fnmatch.filter(filenames, '*Config*.xml'):
>>        fullfn = os.path.join(dirpath, filename)
>>        print fullfn
>>
>> myfile = open("boxids.txt", "r")
>> for line in myfile:
>>    dirname = os.path.join('D:\\Dir\\', line.strip())
>>    findinterestingfiles(dirname):
>> myfile.close()

> Should this code work? I get a syntax error and cannot figure out why.

Sorry, remove the spurious : after findinterestingfiles(dirname) and it  
should work fine.

-- 
Gabriel Genellina




More information about the Python-list mailing list