-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsource.py
97 lines (80 loc) · 2.11 KB
/
source.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
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
import numpy as np
import pytest
def spam(thing,
various=None,
other=None,
things=None):
"""
some very long
doc string
"""
bla = """ another triple quoted string """
X = np.zeros((10,10))
X[0,0] = 1
boing = outer_scope_thing['and']
foo = somelist
do_something = lambda val: spam_spam_spam(val + outer_scope_thing['and'] + boing)
for k in X:
if np.sum(k) != 0:
return [[do_something(val) for val in row] for row in X]
class Hovercraft():
@property
def eels(self):
try:
return spam_spam('')
except Exception as e:
raise Exception('ahoi!') from e
blub = '🐍'
somelist = [1,2,3,np.zeros((23,42)), np.ones((42,23))]
outer_scope_thing = {'various': 'things',
123: 'in a dict',
'and': np.ones((42,23)),
'in a list': somelist}
def deco(f):
bla = '🐍🐍🐍'
def closure(*args, **kwargs):
kwargs['zap'] = bla
return f(*args, **kwargs)
return closure
@deco
def spam_spam(boing, zap='!'):
thing = boing + zap
spam(thing)
def spam_spam_spam(val):
if np.sum(val) != 42:
bla = val.T.\
T.T.\
T
# here is a comment \
# that has backslashes \
# for some reason
eels = "here is a "\
"multi line "\
"string"
foo = f"""here is
{outer_scope_thing["and"]}
a multi-line f-string,
even with quotes in it
"""
# np.reshape(bla, 9000)
try:
bla.nonexistant_attribute
except:
pass
supersecret = "you haven't seen this"
boing = np.\
random.rand(*bla.T.\
T.T)
raise Exception('something happened')
####
@pytest.fixture
def sourcelines():
with open(__file__, 'r') as sf:
lines = sf.readlines()
return lines
if __name__ == '__main__':
import stackprinter
try:
Hovercraft().eels
except:
stackprinter.show(style='darkbg')