From 69df9407118c6741fee4d3bce1016abd5a2ec6ea Mon Sep 17 00:00:00 2001 From: Marco Cammarata Date: Thu, 12 Jan 2017 16:35:36 +0100 Subject: [PATCH] improved DataStorage to add key with the syntax a.data=3 --- xray/storage.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xray/storage.py b/xray/storage.py index 6ab366b..91430e8 100644 --- a/xray/storage.py +++ b/xray/storage.py @@ -119,6 +119,11 @@ class DataStorage(dict): setattr(self,key,value) super().__setitem__(key, value) + def __setattr__(self, key, value): + """ allows to add fields with data.test=4 """ + super().__setitem__(key, value) + super().__setattr__(key,value) + def __delitem__(self, key): delattr(self,key) super().__delitem__(key)