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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
x = r"""
>>> import os
>>> print os
<module 'os' from '/file/path.py'>
>>> for x in range(10):
... y = x + 2
... print(x)
... if x > 5:
... raise Exception
...
0
1
2
3
4
5
6
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
Exception
>>>
>>> while True:
... pass
...
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyboardInterrupt
>>> class A(Exception):pass
...
>>> class B(Exception):pass
...
>>> try:
... try:
... raise A('first')
... finally:
... raise B('second')
... except A as c:
... print(c)
...
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
__main__.A: first
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
__main__.B: second
>>> x =
File "<stdin>", line 1
x =
^
SyntaxError: invalid syntax
>>>
>>> x = 3
>>> with 5 as y:
... print(x + y)
...
8
# TODO
#>>> raise ValueError('multi\n line\ndetail')
#Traceback (most recent call last):
#........
#ValueError: multi
# line
#detail
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
.123
ValueError: multi
line
detail
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
...
ValueError: multi
line
detail
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
....
ValueError: multi
line
detail
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
....
ValueError: multi
line
detail
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
...
ValueError: multi
line
detail
>>> raise Exception
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception
>>> import somemodule
>>> somemodule.blah()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/stuff/somemodule/blah.py", line 658, in blah
raise Exception('Hi.')
Exception: Hi.
|