diff options
Diffstat (limited to 'examples/addons')
-rw-r--r-- | examples/addons/commands-paths.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/addons/commands-paths.py b/examples/addons/commands-paths.py index f37a0fbc..4d9535b9 100644 --- a/examples/addons/commands-paths.py +++ b/examples/addons/commands-paths.py @@ -20,9 +20,9 @@ class MyAddon: for f in flows: totals[f.request.host] = totals.setdefault(f.request.host, 0) + 1 - fp = open(path, "w+") - for cnt, dom in sorted([(v, k) for (k, v) in totals.items()]): - fp.write("%s: %s\n" % (cnt, dom)) + with open(path, "w+") as fp: + for cnt, dom in sorted([(v, k) for (k, v) in totals.items()]): + fp.write("%s: %s\n" % (cnt, dom)) ctx.log.alert("done") |