
4 Mar
2013
4 Mar
'13
12:36 a.m.
When dealing with files it would be nice to avoid an extra block. This is not the same as the __exit__ method because you would have to write a function to just catch an error. BTW, why not "with...except.."? Just like "for" and "while" loops have "else" clauses.
with open('foo') as f: print(f.read()) except IOError: print('Problem with the file!')
-- João Bernardo