forked from qiwsir/StarterLearningPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23901.py
More file actions
19 lines (14 loc) · 421 Bytes
/
23901.py
File metadata and controls
19 lines (14 loc) · 421 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
class RoundFloat(object):
def __init__(self, val):
assert isinstance(val, float), "value must be a float."
self.value = round(val, 2)
def __str__(self):
return "{:.2f}".format(self.value)
__repr__ = __str__
#def __repr__(self):
# return self.__str__()
if __name__ == "__main__":
r = RoundFloat(2.185)
print r
print type(r)