[EMAIL PROTECTED] wrote: > I have: > > try: > for line in open(myFileName): > count += 1 > except IOError: > print "Can't open myfile" > > (I know, this is bad, I never close the file, but its just for > illustration). But then I change it to: > > try: > for line in open(myFileName): > count += openAndProcessSubfile(line) > except IOError: > print "Can't open myfile" > > ... now the 'except' incorrectly catches errors from > openAndProcessSubfile.
The typical way to counter this would be by catching the IOError earlier so it won't propagate to the outmost "try": try: for line in open(myFileName): try: count += openAndProcessSubfile(line) except IOError: print "Can't open subfile" except IOError: print "Can't open myfile" Regards, Björn -- BOFH excuse #121: halon system went off and killed the operators. -- http://mail.python.org/mailman/listinfo/python-list