On Fri, Jan 31, 2014 at 12:11 AM, MRAB <pyt...@mrabarnett.plus.com> wrote: > One of the reasons that the 'with' statement was added was to prevent > the mistake that you've just done. ;-) > > What if the file can't be opened?
Yeah, whoops. The open shouldn't be inside try/finally. def func(): output = open("output.txt", "w") try: # do a whole lot of stuff ... finally: output.close() But my point still stands, I believe :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list