Search code examples
pythonpython-2.7maya

Python > Save help() output to formated html file?


I have a very long output from help() function and found it a bit hard to find what I am looking for in the script editor. Is it possible to save the help() output as a formatted html file?


Solution

  • Yes, you can use the pydoc module to do this in the Python interpreter:

    import pydoc
    pydoc.writedoc("sys")
    

    This code will write the documentation for the sys module to a file sys.html in the current directory. If you want to get documentation for a package, you need to use pydoc.writedocs() instead.

    The Python docs say that you can also run pydoc -w <object> from the command line, but this didn't work for me without including the full path:

    C:\Python27\Lib\pydoc.py -w sys