Let's consider the small script above.
def d(n):
if n==0:
return 0
else:
return d(n−1)
print d(3)
Is there tool that can report each step action as a debugger can do ?
Let's consider the small script above.
def d(n):
if n==0:
return 0
else:
return d(n−1)
print d(3)
Is there tool that can report each step action as a debugger can do ?
You can use Winpdb - A Platform Independent Python Debugger to step through the execution of the script while reviewing the value of each variable at each step, and follow the flow of instructions.
Another option is to use the trace module.
$ python -m trace --trace test.py
--- modulename: threading, funcname: settrace
threading.py(90): _trace_hook = func
--- modulename: t, funcname: <module>
t.py(1): def d(n):
t.py(6): print d(3)
--- modulename: t, funcname: d
t.py(2): if n==0:
t.py(5): return d(n-1)
--- modulename: t, funcname: d
t.py(2): if n==0:
t.py(5): return d(n-1)
--- modulename: t, funcname: d
t.py(2): if n==0:
t.py(5): return d(n-1)
--- modulename: t, funcname: d
t.py(2): if n==0:
t.py(3): return 0
0