git://git.onelab.eu
/
nepi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
systematic use of context managers for dealing with files instead of open()/close...
[nepi.git]
/
examples
/
ccn_emu_live
/
dce.py
diff --git
a/examples/ccn_emu_live/dce.py
b/examples/ccn_emu_live/dce.py
index
79507b5
..
4b51b17
100644
(file)
--- a/
examples/ccn_emu_live/dce.py
+++ b/
examples/ccn_emu_live/dce.py
@@
-168,9
+168,8
@@
def avg_interests(ec, run):
# TODO: DUMP RESULTS TO FILE
# TODO: DUMP GRAPH DELAYS!
- f = open("/tmp/metric", "a+")
- f.write("%.2f\n" % metric)
- f.close()
+ with open("/tmp/metric", "a+") as f:
+ f.write("%.2f\n" % metric)
print(" METRIC", metric)
return metric