为什么ipdb下的help()命令报错

why help() command under ipdb gives an error

ipython 中,我可以发出以下命令,它给了我帮助:

In [1]: help(["foo", "bar", "baz"])

class list(object)
 |  list() -> new empty list
 |  list(iterable) -> new list initialized from iterable's items
 |
 |  Methods defined here:
 |
 |  __add__(...)
 |      x.__add__(y) <==> x+y
 |
 |  __contains__(...)
 |      x.__contains__(y) <==> y in x
...

但是当我在 ipdb 中做同样的事情时,我得到一个错误:

ipdb> help(["foo", "bar", "baz"])
*** No help on (["foo", "bar", "baz"])

为什么?

help是pdb中的一个特殊命令。您需要显式调用 p help(obj) 而不是 help(obj)。如果你只是在 pdb 中单独调用 help,你可以看到区别。