Status: Accepted
Owner: asmeurer
Labels: Type-Defect Priority-Medium

New issue 2535 by asmeurer: Use "with open" instead of "open … close"
http://code.google.com/p/sympy/issues/detail?id=2535

Now that we don't support Python 2.4, we can use with statement context managers. One of the best places to use this is when opening a file. You can do

with open(file) as f:
    do stuff

instead of

f = open(file)
do stuff
f.close()

And it's not only more readable, but also the with statement context manager will automatically close the file, even if an exception is raised.

There are a handful of places in the code where we open() stuff (do git grep "open\("). Remember that to support the with statement in Python 2.5, you have to add "from __future__ import with_statement" to the top of the file.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to