Hi ,
I am trying to save the output of "help('tkinter')" in a text file.
But i get error. I want to know if there is a Way to get the output of help file
redirected to a file , or save in a variable.

By the way , the code i tried was this .It pretty basic try .

>>> file1=open("C:\\Documents and Settings\\achowdhury\\Desktop\\Help xlrd.txt",'w')
>>> file1.writelines(help('xlrd'))

I get the output as the full help of the module, followed by error ,


Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
file1.writelines(help('xlrd'))
TypeError: writelines() requires an iterable argument

The easiest way is to open a cmd shell and type

pydoc tkinter > tkinterhelp.txt

or

pydoc -w tkinter

which creates a file tkinter.html
The best way, however is to type

pydoc -p 9999

and then direct your web browser to http://localhost:9999 . From here you can browse the help of all your python modules.

The easiest way is to open a cmd shell and type

pydoc tkinter > tkinterhelp.txt

or

pydoc -w tkinter

which creates a file tkinter.html
The best way, however is to type

pydoc -p 9999

and then direct your web browser to http://localhost:9999 . From here you can browse the help of all your python modules.

This leads to another problem. Pydoc does not work in windows CMD.
When i ran this command on cmd, the command was not recognized . Do i need to add the path of the file pydoc in Environment? By the way , thanks for the reply.This is my only clue till now.

This leads to another problem. Pydoc does not work in windows CMD.
When i ran this command on cmd, the command was not recognized . Do i need to add the path of the file pydoc in Environment? By the way , thanks for the reply.This is my only clue till now.

I don't know exactly, i'm in linux. Here is the content of my executable /usr/bin/pydoc

#!/usr/bin/python2.6

import pydoc
if __name__ == '__main__':
    pydoc.cli()

You could perhaps write this in a file 'mypydoc.py' and then use

python mypydoc.py tkinter > tkinterhelp.txt

I found the way to do it programmatically

import tkinter
import pydoc

with open("tkinterhelp.txt", "w") as ofh:
    ofh.write(pydoc.render_doc(tkinter))

Notice that the tkinter help is 1 MB long.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.