Re: dynamically modify help text

2010-06-30 Thread Aahz
In article , Thomas Jollans wrote: > >% python2.6 >Python 2.6.5+ (release26-maint, Jun 28 2010, 19:46:36) >[GCC 4.4.4] on linux2 >Type "help", "copyright", "credits" or "license" for more information. class OLD: pass >... class NEW(object): pass >... OLD.__doc__ = "foo" NEW.__

Re: dynamically modify help text

2010-06-29 Thread Thomas Jollans
On 06/29/2010 02:37 AM, Ben Finney wrote: > Brian Blais 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 chan

Re: dynamically modify help text

2010-06-28 Thread Steven D'Aprano
On Tue, 29 Jun 2010 10:37:44 +1000, Ben Finney wrote: > Brian Blais 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 quest

Re: dynamically modify help text

2010-06-28 Thread Ben Finney
Brian Blais 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 c

Re: dynamically modify help text

2010-06-28 Thread Brian Blais
On Jun 28, 2010, at 14:25 , Chris Rebert wrote: On Jun 27, 2010, at 22:37 , Red Forks wrote: Read you doc file and set the __doc__ attr of the object you want to change. __doc__ is normally defined on classes, e.g. `A`, not instances, e.g. `a`. help() looks for __doc__ accordingly. Cheers,

Re: dynamically modify help text

2010-06-28 Thread Christian Heimes
> >>> i.__add__ = __add__ > >>> i+1 > 6 > >>> > > Was this in reference to a specific python version? This doesn't work with new style classes and thus not in Python 3.x. Subclass from object and you'll see the difference. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamically modify help text

2010-06-28 Thread Stephen Hansen
On 6/28/10 1:13 PM, Emile van Sebille wrote: On 6/28/2010 12:02 PM Benjamin Kaplan said... Just to save the OP some trouble later on: this optimization is done for most of the __*__ methods. Overriding __add__ on an instance won't change the behavior of a + b. ActivePython 2.4.1 Build 247 (Act

Re: dynamically modify help text

2010-06-28 Thread Thomas Jollans
On 06/28/2010 10:13 PM, Emile van Sebille wrote: > On 6/28/2010 12:02 PM Benjamin Kaplan said... >> Just to save the OP some trouble later on: this optimization is done >> for most of the __*__ methods. Overriding __add__ on an instance won't >> change the behavior of a + b. > > ActivePython 2.4.1

Re: dynamically modify help text

2010-06-28 Thread Chris Kaynor
On Mon, Jun 28, 2010 at 1:13 PM, Emile van Sebille wrote: > On 6/28/2010 12:02 PM Benjamin Kaplan said... > > Just to save the OP some trouble later on: this optimization is done >> for most of the __*__ methods. Overriding __add__ on an instance won't >> change the behavior of a + b. >> > > Act

Re: dynamically modify help text

2010-06-28 Thread Emile van Sebille
On 6/28/2010 12:02 PM Benjamin Kaplan said... Just to save the OP some trouble later on: this optimization is done for most of the __*__ methods. Overriding __add__ on an instance won't change the behavior of a + b. ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on Python 2.4.1 (#65, Ju

Re: dynamically modify help text

2010-06-28 Thread Benjamin Kaplan
On Mon, Jun 28, 2010 at 11:25 AM, Chris Rebert wrote: > On Mon, Jun 28, 2010 at 11:13 AM, Brian Blais wrote: >> On Jun 27, 2010, at 22:37 , Red Forks wrote: >>> Read you doc file and set the __doc__ attr of the object you want to >>> change. >>> >>> On Monday, June 28, 2010, Brian Blais wrote: >

Re: dynamically modify help text

2010-06-28 Thread Chris Rebert
On Mon, Jun 28, 2010 at 11:13 AM, Brian Blais wrote: > On Jun 27, 2010, at 22:37 , Red Forks wrote: >> Read you doc file and set the __doc__ attr of the object you want to >> change. >> >> On Monday, June 28, 2010, Brian Blais wrote: >>> I know that the help text for an object will give a descrip

Re: dynamically modify help text

2010-06-28 Thread Brian Blais
On Jun 27, 2010, at 22:37 , Red Forks wrote: Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais wrote: I know that the help text for an object will give a description of every method based on the doc string. Is there a way t

Re: dynamically modify help text

2010-06-27 Thread Red Forks
Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais wrote: > Hello, > > I know that the help text for an object will give a description of every > method based on the doc string.  Is there a way to add something to this > text, spec

dynamically modify help text

2010-06-27 Thread Brian Blais
Hello, I know that the help text for an object will give a description of every method based on the doc string. Is there a way to add something to this text, specific to an object, but generated at run- time? I have an object that reads a file, and I would like part of that file to be sh