Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an option to print the output of help()?

Is there an option to print the output of help('myfun'). The behaviour I'm seeing is that output is printed to std.out and the script waits for user input (i.e. type 'q' to continue).

There must be a setting to set this to just dump docstrings.

Alternatively, if I could just dump the docstring PLUS the "def f(args):" line that would be fine too.

Searching for "python help function" is comical. :) Maybe I'm missing some nice pydoc page somewhere out there that explains it all?

like image 824
mathtick Avatar asked Aug 19 '11 15:08

mathtick


People also ask

What does help () do in Python?

Python help() function is used to get the documentation of specified module, class, function, variables etc. This method is generally used with python interpreter console to get details about python objects.

How do you print output function?

Python print() function prints the message to the screen or any other standard output device. Parameters: value(s) : Any value, and as many as you like. Will be converted to string before printed.

What will be the output of print () statement?

The output will be the string literal, without the quotes. If you have a set string or phrase you want to print, you can store it in a variable and pass the variable name as the argument to print() .

What kind of function is help () in Python?

The Python help function is used to display the documentation of modules, functions, classes, keywords, etc.


1 Answers

To get exactly the help that's printed by help(str) into the variable strhelp:

import pydoc
strhelp = pydoc.render_doc(str, "Help on %s")

Of course you can then easily print it without paging, etc.

like image 85
kindall Avatar answered Sep 23 '22 02:09

kindall