"Timo" <[EMAIL PROTECTED]> wrote
I want to check for a file in 3 directories. If the file is found in
1 of the dirs then do something, if the file was found in 2 or 3
dirs, then do something else. I know the paths and filename. How can
this be done?
Lots of ways but one is to write a predicate function that checks if
a file is in a directory:
def inDirectory(fname, dirname):
# your code here returns 1 = True/0 = False
count = inDirectory(fname, dir1) + inDirectory(fname,dir2) +
inDirectory(fname,dir3)
if count == 1: # do something
elif 2 <= count <= 3: # do another
else: # file not found
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor