mne-tools/mne-python — pull request #205 by Eric89GXL (2012-12-01 19:38:40+00:00)
Title: WIP STY: Using with statement for safety and clarity

How do people think on this sort of change? The "with" statement helps ensure we don't end up with open fids, and makes it so that we don't need to put `fid.close()` before throwing any errors. And it makes it so if any of the functions that are called throw their own errors, the fid gets closed. So that's why it gets my vote...

Note that the only things I changed were 1) the "with" statement at the top, 2) adding an indent, and 3) deleting all `fid.close()` calls that precede throwing of errors (and at the end of the function).