systematic use of context managers for dealing with files instead of open()/close...
[nepi.git] / examples / omf / testing / nepi_omf6_plexus_ping_with_traces.py
index fd507cc..01125f3 100644 (file)
@@ -90,13 +90,11 @@ stdout_2 = ec.trace(app2, "stdout")
 # Choose a directory to store the traces, by default
 # It it the folder ehere you run Nepi.
  
-f = open("app1.txt", "w")
-f.write(stdout_1)
-f.close()
+with open("app1.txt", "w") as f:
+    f.write(stdout_1)
 
-g = open("app2.txt", "w")
-g.write(stdout_2)
-g.close()
+with open("app2.txt", "w") as g:
+    g.write(stdout_2)
 
 # Stop Experiment
 ec.shutdown()