-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperty.py
More file actions
45 lines (34 loc) · 955 Bytes
/
property.py
File metadata and controls
45 lines (34 loc) · 955 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
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
from decimal import Decimal
########################################################################
class Fees(object):
'''just for test''' # docment
""""""
def __init__(self):
"""Constructor"""
self._fee = None
@property
def fee(self):
"""
The fee property - the getter
"""
return self._fee
@fee.setter
def fee(self, value):
"""
The setter of the fee property
"""
if isinstance(value, str):
self._fee = Decimal(value)
elif isinstance(value, Decimal):
self._fee = value
@fee.deleter
def fee(self, attr_name):
if self.__getattribute__(attr_name):
self.__delattr__(attr_name)
if __name__ == "__main__":
f = Fees()
f.fee = '1' # setter()
print f.fee # getter()
print f.delete('_fee') # delete() # question: why error?
print f.fee