It is an easy change to bdb.Pdb.runcall and pdb.runcall to let runcall
return the result of the function call, and I'll fix this in 1.2 (I
just never thought of that).
Changing run() to return the value of the expression is not really
possible without changing the interface in an incompatible way, since
it currently accepts statement syntax.
I suppose I could add a function and method runeval() which is like
run() but evaluates an expression. You can also fake this using the
modified runcall(): runcall(eval, "...").
Here's the patch for runcall:
===================================================================
RCS file: /ufs/guido/CVSROOT/python/Lib/bdb.py,v
retrieving revision 1.12
diff -u -1 -r1.12 bdb.py
--- 1.12 1995/02/03 12:50:04
+++ bdb.py 1995/02/17 10:11:54
@@ -294,2 +294,3 @@
sys.settrace(self.trace_dispatch)
+ res = None
try:
@@ -296,3 +297,3 @@
try:
- apply(func, args)
+ res = apply(func, args)
except BdbQuit:
@@ -302,2 +303,3 @@
sys.settrace(None)
+ return res
===================================================================
RCS file: /ufs/guido/CVSROOT/python/Lib/pdb.py,v
retrieving revision 1.20
diff -u -1 -r1.20 pdb.py
--- 1.20 1995/02/03 12:50:02
+++ pdb.py 1995/02/17 10:11:07
@@ -438,3 +438,3 @@
def runcall(*args):
- apply(Pdb().runcall, args)
+ return apply(Pdb().runcall, args)
===================================================================
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>