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
/
planetlab.py
diff --git
a/examples/ccn_emu_live/planetlab.py
b/examples/ccn_emu_live/planetlab.py
index
b2548f3
..
b51925d
100644
(file)
--- a/
examples/ccn_emu_live/planetlab.py
+++ b/
examples/ccn_emu_live/planetlab.py
@@
-172,9
+172,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