Skip to content

Commit a7b42ee

Browse files
committed
use with open rather than manual file open/close
Shorter, more idiomatic code is a good thing.
1 parent b5104f8 commit a7b42ee

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

tools/webidl_binder.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,10 @@ class %s : public %s {
749749

750750
# Write
751751

752-
c = open(output_base + '.cpp', 'w')
753-
for x in pre_c: c.write(x)
754-
for x in mid_c: c.write(x)
755-
c.close()
756-
757-
js = open(output_base + '.js', 'w')
758-
for x in mid_js: js.write(x)
759-
js.close()
752+
with open(output_base + '.cpp', 'w') as c:
753+
for x in pre_c: c.write(x)
754+
for x in mid_c: c.write(x)
755+
756+
with open(output_base + '.js', 'w') as js:
757+
for x in mid_js: js.write(x)
760758

0 commit comments

Comments
 (0)