use 'with' keyword for script stub (recommended with py3).
authorCampbell Barton <ideasman42@gmail.com>
Sat, 17 Aug 2013 05:27:58 +0000 (05:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 17 Aug 2013 05:27:58 +0000 (05:27 +0000)
release/scripts/templates_py/script_stub.py

index 44c7b802e2ce22bffaa0e6e584303663277e0e0e..3f56749f3b3f15a20bd837c391d10cb69c4c2809 100644 (file)
@@ -9,6 +9,6 @@ filename = "my_script.py"
 
 filepath = os.path.join(os.path.dirname(bpy.data.filepath), filename)
 global_namespace = {"__file__": filepath, "__name__": "__main__"}
-file = open(filepath, 'rb')
-exec(compile(file.read(), filepath, 'exec'), global_namespace)
-file.close()
+with open(filepath, 'rb') as file:
+    exec(compile(file.read(), filepath, 'exec'), global_namespace)
+