diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-05-26 00:27:07 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-05-26 00:50:57 +0900 |
commit | 698a715d0c905079b215034d04cb3f1d8e809dd5 (patch) | |
tree | b78c56a74ce3960214c6e51d775846c09e0d288f /sphinx/apidoc.py | |
parent | ebc888d709ec8812bf6e158f919f6da23d38595c (diff) | |
download | sphinx-git-698a715d0c905079b215034d04cb3f1d8e809dd5.tar.gz |
Refactor code using ``with`` syntax
Diffstat (limited to 'sphinx/apidoc.py')
-rw-r--r-- | sphinx/apidoc.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py index 58724fd5a..c0639acdf 100644 --- a/sphinx/apidoc.py +++ b/sphinx/apidoc.py @@ -62,11 +62,8 @@ def write_file(name, text, opts): print('File %s already exists, skipping.' % fname) else: print('Creating file %s.' % fname) - f = open(fname, 'w') - try: + with open(fname, 'w') as f: f.write(text) - finally: - f.close() def format_heading(level, text): |