How do you see the return value from a function in the Python debugger, without an intermediate?

You can look into a hidden __return__ local variable.

If I would forget it's exact name, I explore it by this:

(Pdb) sorted(locals().keys())
['__return__', 'xyz', ...]

EDIT: Related later answer with example of debugging with __return__


In pdb, when the function returns a ->'value' is added at the end of the line with the representation of the returned value.

For example:

(Pdb) s
--Return--
> test.py(12)do_stuff()->'f'
-> return result
(Pdb) q

means do_stuff() returned 'f'