'How to global search Python documentation from the shell?

pydoc is nice to look up Python documentation for a method foobar from the shell. But it requires me to know both what module a particular method foobar belongs to.

Lets say I just saw a call to some foobar in some code. I just want to do a global search to find out all the methods/classes/constants named foobar in the Python standard library. If I don't know what modules I want to search, I cannot really do a "search" using pydoc.

Is there a way to go a global search for foobar in the Python documentation from the shell?

Example:

$ pydoc3 randrange
No Python documentation found for 'randrange'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

$ pydoc3 -k randrange
<returns nothing>

I need to know beforehand that randrange is from the random module to look up its documentation:

$ pydoc3 random.randrange
<works>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source