Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading python documentation in the terminal?

Is there a way to install the python documentation that would make it available as if it was a manpage? (I know you can download the sourcefiles for the documentation and read them in vim, using less or whatever but I was thinking about something a bit less manual. Don't want to roll my own.)

like image 402
Var87 Avatar asked Jun 22 '17 10:06

Var87


People also ask

How do I run pydoc in terminal?

You can access the interactive shell in pydoc using it's help function. In order to do this, launch your terminal, and enter the python interactive shell. Now, import pydoc and then use the pydoc. help() command to launch the interactive shell.

How do you do documentation in Python?

As you learned that docstrings are accessible through the built-in Python __doc__ attribute and the help() function. You could also make use of the built-in module known as Pydoc , which is very different in terms of the features & functionalities it possesses when compared to the doc attribute and the help function.


4 Answers

I don't know if that's exactly what you are looking for, but the python interactive console offers a help command. You can use it in the following manner.

>>> help()

Welcome to Python 3.6's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/3.6/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".

help> list

This will output the whole documentation for all of the list methods.

like image 53
Lysandros Nikolaou Avatar answered Oct 19 '22 04:10

Lysandros Nikolaou


I don't if this is what you wanted but you everything you can do in IDLE you can do on the command line. Example:

C:>python
>>help(print())
>>help(plt.plot())

This way you can access documentation

like image 43
GiodoAldeima Avatar answered Oct 19 '22 04:10

GiodoAldeima


It's not an exact copy of the documentation, but there's the builtin help() function.

In an interactive python session, you just call help(whatever_you_want_to_read_about), for example:

>>> help(all)
Help on built-in function all in module builtins:

all(...)
    all(iterable) -> bool

    Return True if bool(x) is True for all values x in the iterable.
    If the iterable is empty, return True.

Alternatively, you can start an interactive help session like this:

C:\Users\Rawing>python -c "help()"

Welcome to Python 3.4!  This is the interactive help utility.

help>

And then just type the function/class/module you want to know about:

help> all
Help on built-in function all in module builtins:

all(...)
    all(iterable) -> bool

    Return True if bool(x) is True for all values x in the iterable.
    If the iterable is empty, return True.
like image 16
Aran-Fey Avatar answered Oct 19 '22 03:10

Aran-Fey


On Debian (and derived distributions, like Ubuntu) install pydoc package. Then you can use pydoc whatever command.

like image 11
Błotosmętek Avatar answered Oct 19 '22 03:10

Błotosmętek