How to use the docstring in this property example
Robert
rxjwg98 at gmail.com
Wed Jan 20 23:00:14 EST 2016
Hi,
I read below code snippet on link:
https://docs.python.org/2/library/functions.html#property
--------------
class C(object):
def __init__(self):
self._x = None
def getx(self):
return self._x
def setx(self, value):
self._x = value
def delx(self):
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
If c is an instance of C, c.x will invoke the getter, c.x = value will invoke the setter and del c.x the deleter.
If given, doc will be the docstring of the property attribute.
////////////////
I can use these:
c.x
c.x=42
del c.x
but I don't know how to get the doctring from the property attribute.
Could you show me how to do that?
Thanks,
More information about the Python-list
mailing list