On Tue, Jul 7, 2009 at 6:36 PM, David <da...@pythontoo.com> wrote: > My question is I tried to get it to print out when the directory was empty > like this; > > for file in fobj: > pathname = os.path.join(folder, file) > if os.path.exists(pathname): > print 'removing... ', file > os.remove(pathname) > else: > print 'No files to clean' > > But if there are no files in the directory it never gets to the else. >
It shouldn't, the way you've got it set up... As I read your program, the only way it would get to the "else" would be if some other process deleted one of the files in the directory AFTER your script got a directory listing, but before your script gets around to deleting it. -- www.fsrtechnologies.com
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor