From 5879df5c03f5e2f75a2442436bda43b0e3bb0dc7 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 May 2019 10:36:41 +0100 Subject: [PATCH] Move `as_dict` property to its own method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This helps declutter the init method, and is one less thing to create in memory when it’s not needed. --- app/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index 83774dc06..a3a82295d 100644 --- a/app/utils.py +++ b/app/utils.py @@ -226,7 +226,10 @@ class Spreadsheet(): def __init__(self, csv_data, filename=''): self.filename = filename self.as_csv_data = csv_data - self.as_dict = { + + @property + def as_dict(self): + return { 'file_name': self.filename, 'data': self.as_csv_data }