From 652116e107f437cee8dd2f46603cb0f1961db4ed Mon Sep 17 00:00:00 2001 From: "michele.maris" <maris@oats.inaf.it> Date: Fri, 2 Dec 2022 10:27:50 +0100 Subject: [PATCH] u --- src/yapsut/struct.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/yapsut/struct.py diff --git a/src/yapsut/struct.py b/src/yapsut/struct.py new file mode 100644 index 0000000..4fc52dc --- /dev/null +++ b/src/yapsut/struct.py @@ -0,0 +1,21 @@ +class struct : + """ class used to emulate a C struct, members are seen as attributes + self.keys() returns the list of elements + """ + def keys(self) : + return self.__dict__.keys() + def __setitem__(self,this,that) : + self.__dict__[this]=that + def __getitem__(self,this) : + return self.__dict__[this] + def __repr__(self) : + out=[] + for k in self.keys() : + out['('+k+':'+str(self[k])+')'] + return '('+(','.join(out))+')' + def __init__(self) : + return + if od is None : + return + for k in od.keys() : + self.__dict__[k] = od[k] -- GitLab