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?
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
another option that may be worth mentioning is: redirect the standard output to a file, but this will give you a text file instead of a html
for example
import sys
with open("range help.txt","w") as archi:
t = sys.stdout
sys.stdout = archi
help(range)
sys.stdout = t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With