Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Importing pydoc and then using it natively?

Tags:

python

pydoc

I know how to use pydoc from the command line. However, because of complicated environmental setup, it would be preferable to run it within a python script as a native API call. That is, my python runner looks a bit like this:

import pydoc pydoc.generate_html_docs_for(someFile)

However, it's not clear to me from the pydoc documentation which function calls I need to use to make this behavior work. Any ideas?

like image 945
Stephen Gross Avatar asked Jul 20 '09 20:07

Stephen Gross


People also ask

How do I run pydoc in Python?

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.

What does pydoc do in Python?

The pydoc module automatically generates documentation from Python modules. The documentation can be presented as pages of text on the console, served to a web browser, or saved to HTML files.

What is import * in Python?

Python code in one module gains access to the code in another module by the process of importing it. The import statement is the most common way of invoking the import machinery, but it is not the only way. Functions such as importlib.


1 Answers

Do you mean something like this?

>>> import pydoc
>>> pydoc.writedoc('sys')
wrote sys.html
>>>
like image 63
rob Avatar answered Sep 23 '22 22:09

rob