-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo unrepl.py
56 lines (50 loc) · 859 Bytes
/
demo unrepl.py
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
import unrepl
repl_output = """\
>>> import math
>>> angle = 90
>>> math.radians(90)
1.5707963267948966
>>> math.pi / 2
1.5707963267948966
"""
unrepled = unrepl.unrepl(repl_output, use_print_statements=True)
print(unrepled)
print("execute ...")
exec(unrepled)
repl_output = """\
>>> def square(x):
... (1, 2, 'ab')
(1, 2, 'ab')
... return x * x
>>> a=0
>>> b=2
>>> a+b
2
>>> square(_) * 'test'
'testtesttesttest'
"""
print("-----")
unrepled = unrepl.unrepl(repl_output, use_print_statements=True)
print(unrepled)
print("execute ...")
exec(unrepled)
repl_output = """\
>>> for i in range(5):
... i * i
...
...
0
1
4
9
16
>>> _
16
"""
print("-----")
unrepled = unrepl.unrepl(repl_output, use_print_statements=True)
print(unrepled)
print("execute ...")
exec(unrepled)
from unrepl import unrepl
raise unrepl.IncorrectClipboardError('jj')