systematic use of context managers for dealing with files instead of open()/close...
[nepi.git] / src / nepi / resources / ns3 / ns3wrapper_debug.py
index 7368448..332f63b 100644 (file)
@@ -48,9 +48,8 @@ class NS3WrapperDebuger(object):
         return self._script_path
 
     def dump_to_script(self, command):
-        f = open(self.script_path, "a")
-        f.write("%s" % command)
-        f.close()
+        with open(self.script_path, "a") as f:
+            f.write("%s" % command)
 
     def dump_header(self):
         if not self.enabled: