7

Help is available in a standard IPython shell via the help command or by using the ? character. For example, for help on the built-in sum function, either of the below commands in an IPython shell could be used.

In [1]: help(sum)
Help on built-in function sum in module builtin:
...

In [2]: sum?
Signature: sum(iterable, start=0, /)
Docstring: ...

I want to have the same functionality in an ipdb debugger. One enters an ipdb debugger by placing the below code at the location for a debug breakpoint.

from ipdb import set_trace
set_trace()

However, once inside the ipdb debugger the Help functions no longer work.

ipdb> help(sum)
*** No help for '(sum)'
ipdb> sum?
*** SyntaxError: invalid syntax
ipdb>

Help in IPython shell and ipdb debugger

The below command represents a way to print a docstring inside the ipdb debugger, however this is not exactly the same functionality as help(sum) and sum? in the IPython shell.

ipdb> print(sum.__doc__)

How then do I get the same help functionality in an ipdb debugger that exists in the IPython shell?

2
  • 1
    Interesting that you don't get help, as that's a python builtin. Commented Nov 8, 2016 at 5:53
  • 1
    Ah. help help you may find useful. Commented Nov 8, 2016 at 5:54

1 Answer 1

12

It looks like you can preface it with a ! (which is short for exec)

ipdb> !help(sum)
Help on built-in function sum in module builtins:

sum(iterable, start=0, /)
    Return the sum of a 'start' value (default: 0) plus an iterable of numbers

    When the iterable is empty, return the start value.
    This function is intended specifically for use with numeric values and may
    reject non-numeric types.
(END)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.