How to override the doc of an object instance.

David Huard david.huard at
Wed Jun 21 06:50:50 CEST 2006


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
        print self._x, 'Ok'
    x = property(fget = fget, fset = fset, doc= "It prints")

print widget.x.__doc__

w = widget()
w.x = 5
print w.x.__doc__

I would like the last statement to print the doc string that I specified in
property, instead of the docstring for an int. The goal is to have ipython print
that string with the command 
So the user knows what this attribute does, and how he can set it. 

Is this possible ? 


David Huard

More information about the Python-list mailing list