pydoc

How do I export the output of Python's built-in help() function

。_饼干妹妹 提交于 2019-11-27 22:55:08
I've got a python package which outputs considerable help text from: help(package) I would like to export this help text to a file, in the format in which it's displayed by help(package) How might I go about this? Michael0x2a This is a bit hackish (and there's probably a better solution somewhere), but this works: import sys import pydoc def output_help_to_file(filepath, request): f = open(filepath, 'w') sys.stdout = f pydoc.help(request) f.close() sys.stdout = sys.__stdout__ return And then... >>> output_help_to_file(r'test.txt', 're') Aaron Altman pydoc.render_doc(thing) to get thing's help

How do I export the output of Python's built-in help() function

故事扮演 提交于 2019-11-27 17:39:15
问题 I've got a python package which outputs considerable help text from: help(package) I would like to export this help text to a file, in the format in which it's displayed by help(package) How might I go about this? 回答1: This is a bit hackish (and there's probably a better solution somewhere), but this works: import sys import pydoc def output_help_to_file(filepath, request): f = open(filepath, 'w') sys.stdout = f pydoc.help(request) f.close() sys.stdout = sys.__stdout__ return And then... >>>

Pydoc is not working (Windows XP)

ぐ巨炮叔叔 提交于 2019-11-27 05:53:03
问题 Using Windows XP and Python 2.7 I tried to run "pydoc" through the terminal. unfortunately it doesn't work. Since I'm not allowed to post a screenshot (Newbie). Here is what it says (white on black) What I type: "C:\Python27>pydoc raw_input /"pydoc raw_input" My result (It's German an it roughly translates to"The command "pydoc" is either spelled wrong or couldn't be found.): Der Befehl "pydoc" ist entweder falsch geschrieben oder konnte nicht gefunden werden. What am I doing wrong? By the