Re: How to override the doc of an object instance.

2006-06-21 Thread David Huard
It works ! Wow. Thanks a lot. If you don't mind, I'll post your code to the ipython list so it can be reused. David -- http://mail.python.org/mailman/listinfo/python-list

Re: How to override the doc of an object instance.

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 17:00, Paul McGuire a écrit : > No need to, just assign your special docstrings to w.x.__doc__, and print > w.x.__doc__.  Instances that have special docstrings will print their > instance-specific versions; instances without instance-specific docstrings > will print the cl

Re: How to override the doc of an object instance.

2006-06-21 Thread Bruno Desthuilliers
David Huard wrote: (snip) > Has this problem come up before ? > It seems that with the new classes, this > kind of wish will generalize, AFAIK, there's no (and never have been) docstrings for non-callable attributes of a class or module. And properties are non-callable attributes. > or is it a b

Re: How to override the doc of an object instance.

2006-06-21 Thread David Huard
On Wed, 21 Jun 2006 17:15:16 +0200, Maric Michaud wrote: > > In [53]: class a(object) : >: x=property(lambda s: 0, doc='my doc string') >: >: > > In [54]: b=a() > > In [55]: help(b) I agree it works, but for a class with tens of attributes, this is not very practical

Re: How to override the doc of an object instance.

2006-06-21 Thread David Huard
Paul, Although your solution works for the class itself, it doesn't for class attributes, since they point to built-ins whose attributes are read-only. >>> w.x.__doc__ = widget.x.__doc__ AttributeError: 'int' object attribute '__doc__' is read-only Would the solution be to build a new type and

Re: How to override the doc of an object instance.

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 15:58, David Huard a écrit : > On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > > This is w.__class__.x.__doc__. > > Thanks, > > So in order to implement what I want, I should rather consider an > ipython hack to print w.__class__.x.__doc__ when it exists, instead

Re: How to override the doc of an object instance.

2006-06-21 Thread Paul McGuire
"David Huard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > > > This is w.__class__.x.__doc__. > > Thanks, > > So in order to implement what I want, I should rather consider an > ipython hack to print w.__class__.x.__doc__ w

Re: How to override the doc of an object instance.

2006-06-21 Thread David Huard
On Wed, 21 Jun 2006 15:39:02 +0200, Maric Michaud wrote: > This is w.__class__.x.__doc__. Thanks, So in order to implement what I want, I should rather consider an ipython hack to print w.__class__.x.__doc__ when it exists, instead of w.x.__doc_ ? Does this makes sense or it will ruin the stand

Re: How to override the doc of an object instance.

2006-06-21 Thread Maric Michaud
Le Mercredi 21 Juin 2006 06:50, David Huard a écrit : > class widget (object): >     """This is a widget.""" >     def  __init__(self): >         self._x = None >     def fget(self): >         return self._x >     def fset(self, value): >         self._x = value >         print self._x, 'Ok' >    

How to override the doc of an object instance.

2006-06-21 Thread David Huard
Hi, I'm not really sure about the right terminology, but here is my question, boiled down to this code: class widget (object): """This is a widget.""" def __init__(self): self._x = None def fget(self): return self._x def fset(self, value): self._x = value