Reputation: 69934
pdb, the default Python debugger, has an undocumented (?) retval
command that prints the return value of the current function if you already computed it and are one step away from returning back to the caller frame.
Is there similar functionality in the graphical Winpdb debugger? I can't find the return value anywhere and it does not recognize retval as a command.
By the way, I know I could just add an intermediary variable and inspect that instead but I would like to avoid having to edit the code I'm debugging, specially when its from a third party library.
#original code
def f(x):
return x+1
#debugging code
def f(x):
r = x+1
return r
Finally, I'm also open to alternative debuggers as long as they have a GUI, run on Linux and don't come bundled inside an IDE.
Upvotes: 2
Views: 645
Reputation: 24314
In the console
bp filename.py:f
to set a breakpoint on f
go
and wait for breakpoint to be triggered.r
or return
v
or eval
to get the value, e.g v x+1
Upvotes: 1
Reputation: 91490
Does a curses GUI count? The PuDB debugger runs in the terminal, but has a curses-based GUI. See the screenshot
(don't be turned off by the blue, there are other themes as well).
It has the feature you want, when you step over a return statement, it stops and shows you the return value. See the screenshot below
Upvotes: 1