Skip to content

Commit

Permalink
Merge pull request #4327 from abhinav-upadhyay/use-with-to-read-file
Browse files Browse the repository at this point in the history
Use the with statement to open a file.
  • Loading branch information
takluyver committed Oct 2, 2013
2 parents 4d6aad3 + ef5a828 commit 6676b20
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions IPython/core/magics/code.py
Expand Up @@ -402,9 +402,8 @@ def _edit_macro(self,mname,macro):
self.shell.hooks.editor(filename)

# and make a new macro object, to replace the old one
mfile = open(filename)
mvalue = mfile.read()
mfile.close()
with open(filename) as mfile:
mvalue = mfile.read()
self.shell.user_ns[mname] = Macro(mvalue)

@skip_doctest
Expand Down

0 comments on commit 6676b20

Please sign in to comment.