pdb.run/runcall return values?

Mark Lutz (mlutz@KaPRE.COM)
Thu, 16 Feb 1995 10:27:24 +0700

Is there a direct way to get the result of a string or
function call run under pdb?

I want to be able to route embedded calls to the debugger
if a switch is set, but return the result to the caller,
so it can continue. I can do it now, by:

- to run a string expression 'str':
if debugging
pdb.run("_res = <str>")
res = getattr(main, "_res")
else
res = run_string(<str>,...)

- to run a func(*args):
predefine a dummy function:
def runit(func, args):
global _res
_res = apply(func, args)
if debugging
pdb.runcall(dummy.runit, func, args)
res = getattr(dummy, "_res")
else
res = call_object(func, args)

but this seems a roundabout way of doing it. Is there an
easy way to do this (subclassing Pdb,...)?

Mark L.