The question is, how can I configure the Python debugger to show me in the console what functions are being called?
In order not to see everything flash by, a delay between the function calls would be needed.
The question is, how can I configure the Python debugger to show me in the console what functions are being called?
In order not to see everything flash by, a delay between the function calls would be needed.
You can use the alternative pydb debugger. You can invoke it with pydb --fntrace --batch <scriptname>
to get a function trace.
As for the "flashing-by", use the usual tools like Ctrl-S/Ctrl-Q on an ANSI terminal, or redirect to a file.
If you want to monitor when a few particular functions are being called, you could use this decorator:
import functools
def trace(f):
@functools.wraps(f)
def wrapper(*arg,**kw):
'''This decorator shows how the function was called'''
arg_str=','.join(['%r'%a for a in arg]+['%s=%s'%(key,kw[key]) for key in kw])
print "%s(%s)" % (f.__name__, arg_str)
return f(*arg, **kw)
return wrapper
You would use it like this:
@trace # <--- decorator your functions with the @trace decorator
def foo(x,y):
# do stuff
When you run your program, every time foo(x,y) is called, you'll see the function call with the value of its arguments in the console:
foo(y=(0, 1, 2),x=(0, 0, 0))