pysnooper.debug 定义debug的函数调用层级 添加非局部变量的修改记录

1

定义debug的函数调用层级

1
@pysnooper.snoop("test.log", depth=2)

添加非局部变量的修改记录

1
@pysnooper.snoop("test.log", variables=('K', 'P'))
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
import pysnooper


K = 0


def (i):
global K
K += 1
j = i ** 2
return j


def g(i):
global K
K += 1
j = i + f(i)
return j



@pysnooper.snoop("test.main.log", depth=1)
def main():
for i in range(4):
print(g(i))


if __name__ == '__main__':
main()