-
Notifications
You must be signed in to change notification settings - Fork 0
/
_selectors.main.py
46 lines (43 loc) · 1.39 KB
/
_selectors.main.py
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
37
38
39
40
41
42
43
44
45
46
from _selectors import *
@selectors({'get': ['data','size'], 'set':['data', 'label']})
@private('data', 'size')
class E:
def __init__(self, label, start):
self.label = label
self.data = start
self.size = len(self.data)
@selectors({'get': ['data','size'], 'set':['data', 'label']})
@private('data', 'size', 'label')
class D:
def __init__(self, label, start):
self.label = label
self.data = start
self.size = len(self.data)
def double(self):
for i in range(self.size):
self.data[i] = self.data[i] * 2
def display(self):
print('{0} => {1}'.format(self.label, self.data))
if __name__ == "__main__":
try:
Y = E('Wrong Label', ['a', 'b'])
except Exception as e: print("{0}: {1}".format(type(e).__name__, e))
X = D('X is', [1, 2, 3])
X.display(); X.double(); X.display()
try:
print(X.size)
except Exception as e: print("{0}: {1}".format(type(e).__name__, e))
try:
print(X.data)
except Exception as e: print("{0}: {1}".format(type(e).__name__, e))
print(X.getData())
X.setData([25])
print(X.getSize())
try:
X.setSize(25)
except Exception as e: print("{0}: {1}".format(type(e).__name__, e))
try:
print(X.getLabel())
except Exception as e: print("{0}: {1}".format(type(e).__name__, e))
X.setLabel('It has worked!!!')
X.display()