1

I want to assign a help() page to a variable as a string; for example

a = help("class")
print a

Is this possible and how would I go about doing it?

0

2 Answers 2

7

You can retrive the documentation directly.

from pydoc_data import topics

a = topics.topics['class']
print a
Sign up to request clarification or add additional context in comments.

Comments

3
import pydoc

a = pydoc.render_doc('class')
print a

2 Comments

This dont seem to work... Traceback (most recent call last): File "/media/Storage/Workspace/tmp/justsome.py", line 3, in <module> a = pydoc.render_doc('class') File "/usr/lib/python2.7/pydoc.py", line 1507, in render_doc object, name = resolve(thing, forceload) File "/usr/lib/python2.7/pydoc.py", line 1499, in resolve raise ImportError, 'no Python documentation found for %r' % thing ImportError: no Python documentation found for 'class'
Sorry, I took 'class' to mean a generic place holder. Not the actual help() topic 'class'. It does work for actual classes. Try it with 'pprint' or 'set'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.