From ac7c65e29f9a44dba4142dd21e6f9b32032c6bd7 Mon Sep 17 00:00:00 2001 From: neingeist Date: Fri, 29 Aug 2014 22:39:38 +0200 Subject: [PATCH] write pretty json output --- json_memoize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/json_memoize.py b/json_memoize.py index 4b62f9c..6df65b5 100644 --- a/json_memoize.py +++ b/json_memoize.py @@ -32,7 +32,11 @@ def json_memoize(filename): if json_key not in memo: memo[json_key] = self.fn(*args, **kwargs) with open(filename, "w") as f: - json.dump(memo, f) + json.dump(memo, f, + indent=4, + separators=(',', ': '), + sort_keys=True) + f.write("\n") return memo[json_key] return JsonMemoize