Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion dynamically modify help text
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Steven D'Aprano  
View profile  
 More options Jun 28 2010, 10:19 pm
Newsgroups: comp.lang.python
From: Steven D'Aprano <steve-REMOVE-T...@cybersource.com.au>
Date: 29 Jun 2010 02:19:34 GMT
Local: Mon, Jun 28 2010 10:19 pm
Subject: Re: dynamically modify help text

On Tue, 29 Jun 2010 10:37:44 +1000, Ben Finney wrote:
> Brian Blais <bbl...@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"

True, but what you can't do is:

a = A()
a.__doc__ = "new docstring"

unless you jump through hoops with __getattribute__ or descriptors.

--
Steven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.