-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.py
More file actions
36 lines (26 loc) · 804 Bytes
/
table.py
File metadata and controls
36 lines (26 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import re
class Table:
def __init__(self, data={}):
self.__data = data
def __nonzero__(self):
return True
def __ne__(self, other):
return False
def __eq__(self, other):
return False
def __iter__(self):
return iter(self.__data.items())
def __str__(self):
return "|" + "|".join("%s = %s" % (k, v,) for k, v in self.__data.items()) + "|"
def __getattr__(self, name):
if name in self.__data:
return self.__data[name]
elif name in self.__dict__:
return self.__dict__[name]
else:
return None
def __setattr__(self, name, value):
if re.match("_\w+__\w+", name):
self.__dict__[name] = value
else:
self.__data[name] = value