improved DataStorage to add key with the syntax a.data=3

This commit is contained in:
Marco Cammarata 2017-01-12 16:35:36 +01:00
parent 1f652ab162
commit 69df940711
1 changed files with 5 additions and 0 deletions

View File

@ -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)