X Tutup
Skip to content

Commit 9fa5f8d

Browse files
committed
Use with
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent d927418 commit 9fa5f8d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

bpython/repl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,8 @@ def write2file(self):
761761
s = self.formatforfile(self.getstdout())
762762

763763
try:
764-
f = open(fn, mode)
765-
f.write(s)
766-
f.close()
764+
with open(fn, mode) as f:
765+
f.write(s)
767766
except IOError:
768767
self.interact.notify("Disk write error for file '%s'." % (fn, ))
769768
else:

0 commit comments

Comments
 (0)
X Tutup