-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherr_handling.py
More file actions
46 lines (35 loc) · 822 Bytes
/
Copy patherr_handling.py
File metadata and controls
46 lines (35 loc) · 822 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
46
#!/usr/bin/env python3
import logging
logging.basicConfig(level=logging.INFO)
import pdb
print('--------------First one-------------------------')
def foo(s):
n = int(s)
if n==0:
raise ValueError('Invalid value: %s' % s)
return 10/n
def bar():
try:
foo('0')
except ValueError as e:
print('ValueError!')
raise
#bar()
print('-------------Second one-----------------------')
def foo(s):
n = int(s)
assert n != 0, 'n is zero!'
return 10/n
def main():
foo('0')
#main()
#print('-----------Third one-----------------------------')
#s = '0'
#n = int(s)
#logging.info('n = %d' % n)
#print(10 / n)
print('-----------Fourth one-----------------------------')
s = '0'
n = int(s)
pdb.set_trace()
print(10 / n)