Longtomjr
Longtomjr

Reputation: 131

Assign help() to a variable

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?

Upvotes: 1

Views: 122

Answers (2)

che2cbs
che2cbs

Reputation: 369

import pydoc

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

Upvotes: 3

nymk
nymk

Reputation: 3393

You can retrive the documentation directly.

from pydoc_data import topics

a = topics.topics['class']
print a

Upvotes: 7

Related Questions