all Python 3pdbfunction
pdb.runcall()
running under the debugger
Calls a function with arguments under the debugger: it stops at the first line of its body and returns its result.
Syntax
pdb.runcall(function, *args, **kwds)
You pass the function and its arguments separately, runcall(f, 3, 4), not runcall(f(3, 4)): in the latter f runs before the debugger and it receives a finished number. It stops inside the function, not on the calling line, so the arguments are visible at once with the args (a) command.
Examples
import io, sys, pdb
def area(w, h):
return w * h
sys.stdin = io.StringIO('a\nc\n')
sys.stdout = log = io.StringIO()
result = pdb.runcall(area, 3, h=4)
sys.stdout = sys.__stdout__
print(result) # → 12
print(log.getvalue().split('(Pdb) ')[1].split()) # → ['w', '=', '3', 'h', '=', '4']
See also
Open in the full glossarydocs.python.orgReport an inaccuracy