I have just discovered that the syntax

with file(name, 'w') as f:
   do_something(f)

does not close the file at the end of the with statement! On the
contrary

with open(name, 'w') as f:
   do_something(f)

works fine. The docs say "When opening a file, it’s preferable to use
open() instead of invoking this constructor directly." but perhaps
they should mention why :(

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to