[Tutor] Remove
Jon Cosby
jcosby@mindspring.com
Mon, 10 Sep 2001 08:10:26 -0700
I'm doing a Web search that is succesful until I try to configure it to
ignore specified directories using the "remove" operation. I'm not getting
any error messages, but the script stops when it comes to the function
below. I've run the first few lines in the interpreter, and I can't see
anything wrong with it. Any ideas?
def getFile(text, dir):
hits = []
dl = os.listdir(dir)
for item in ignore: # List of directories to ignore
dl.remove(item) # Works in interpreter, but list comes up empty here
text = string.lower(text)
for d in dl:
d = dir + '\\' + d
if os.path.isfile(d):
hits.extend(searchtext(d, text))
elif os.path.isdir(d):
hits.extend(getFile(text, d))
return hits
Jon Cosby
jcosby@mindspring.com
www.jcosby.com