回答編集履歴
1
修正
test
CHANGED
@@ -10,8 +10,6 @@
|
|
10
10
|
|
11
11
|
def spam1():
|
12
12
|
|
13
|
-
print('spam')
|
14
|
-
|
15
13
|
try:
|
16
14
|
|
17
15
|
print('try')
|
@@ -22,17 +20,11 @@
|
|
22
20
|
|
23
21
|
print('finally')
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
print('return')
|
28
|
-
|
29
23
|
|
30
24
|
|
31
25
|
@contextmanager
|
32
26
|
|
33
27
|
def spam2():
|
34
|
-
|
35
|
-
print('spam')
|
36
28
|
|
37
29
|
print('try')
|
38
30
|
|
@@ -40,49 +32,41 @@
|
|
40
32
|
|
41
33
|
print('finally')
|
42
34
|
|
43
|
-
|
35
|
+
|
44
36
|
|
45
37
|
|
46
38
|
|
47
|
-
p
|
39
|
+
for spam in [spam1, spam2]:
|
48
40
|
|
49
|
-
t
|
41
|
+
print('-'*48)
|
50
42
|
|
51
|
-
|
43
|
+
try:
|
52
44
|
|
53
|
-
|
45
|
+
with spam():
|
54
46
|
|
55
|
-
|
47
|
+
print('with')
|
56
48
|
|
57
|
-
|
49
|
+
raise Exception
|
58
50
|
|
59
|
-
|
51
|
+
except Exception:
|
60
52
|
|
61
|
-
print('
|
53
|
+
print('exception')
|
62
54
|
|
63
|
-
try:
|
64
55
|
|
65
|
-
with spam2():
|
66
|
-
|
67
|
-
raise Exception
|
68
|
-
|
69
|
-
except Exception:
|
70
|
-
|
71
|
-
print('exception')
|
72
56
|
|
73
57
|
```
|
74
58
|
|
75
59
|
|
76
60
|
|
77
|
-
**実行結果** [Wandbox](https://wandbox.org/permlink/
|
61
|
+
**実行結果** [Wandbox](https://wandbox.org/permlink/HLq8S1n1RIzmt0bV)
|
78
62
|
|
79
63
|
```
|
80
64
|
|
81
65
|
------------------------------------------------
|
82
66
|
|
83
|
-
|
67
|
+
try
|
84
68
|
|
85
|
-
t
|
69
|
+
with
|
86
70
|
|
87
71
|
finally
|
88
72
|
|
@@ -90,9 +74,9 @@
|
|
90
74
|
|
91
75
|
------------------------------------------------
|
92
76
|
|
93
|
-
|
77
|
+
try
|
94
78
|
|
95
|
-
t
|
79
|
+
with
|
96
80
|
|
97
81
|
exception
|
98
82
|
|