forked from qiwsir/StarterLearningPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21602.py
More file actions
18 lines (16 loc) · 409 Bytes
/
21602.py
File metadata and controls
18 lines (16 loc) · 409 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
# coding=utf-8
class Calculator(object):
is_raise = False
def calc(self, express):
try:
return eval(express)
except ZeroDivisionError:
if self.is_raise:
print "zero can not be division."
else:
raise
if __name__ == "__main__":
c = Calculator()
c.is_raise = True
print c.calc("8/0")