dynamically modify help text
Ben Finney
ben+python at benfinney.id.au
Mon Jun 28 20:37:44 EDT 2010
Brian Blais <bblais at bryant.edu> writes:
> On Jun 28, 2010, at 14:25 , Chris Rebert wrote:
> > __doc__ is normally defined on classes, e.g. `A`, not instances,
> > e.g. `a`. help() looks for __doc__ accordingly.
>
> so that gets back to my original question: can I change this text at
> runtime. Doesn't look like I can, because it is defined for classes
> rather than instances. Am I thinking about this correctly?
Classes are objects. You can change the ‘__doc__’ attribute of a class
object the same as you'd change it for any other object::
A.__doc__ = "new docstring"
--
\ “All television is educational television. The question is: |
`\ what is it teaching?” —Nicholas Johnson |
_o__) |
Ben Finney
More information about the Python-list
mailing list