[Python-checkins] cpython (3.3): Document that @property can incorporate a docstring from the getter method.

raymond.hettinger python-checkins at python.org
Sun Nov 24 23:54:15 CET 2013


http://hg.python.org/cpython/rev/5ea2e6e3e3d3
changeset:   87527:5ea2e6e3e3d3
branch:      3.3
parent:      87517:cbd78679080b
user:        Raymond Hettinger <python at rcn.com>
date:        Sun Nov 24 14:53:29 2013 -0800
summary:
  Document that @property can incorporate a docstring from the getter method.  Improve readabilty with additional whitespace.

files:
  Objects/descrobject.c |  14 +++++++++-----
  1 files changed, 9 insertions(+), 5 deletions(-)


diff --git a/Objects/descrobject.c b/Objects/descrobject.c
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1512,21 +1512,25 @@
 "\n"
 "fget is a function to be used for getting an attribute value, and likewise\n"
 "fset is a function for setting, and fdel a function for del'ing, an\n"
-"attribute.  Typical use is to define a managed attribute x:\n"
+"attribute.  Typical use is to define a managed attribute x:\n\n"
 "class C(object):\n"
 "    def getx(self): return self._x\n"
 "    def setx(self, value): self._x = value\n"
 "    def delx(self): del self._x\n"
 "    x = property(getx, setx, delx, \"I'm the 'x' property.\")\n"
 "\n"
-"Decorators make defining new properties or modifying existing ones easy:\n"
+"Decorators make defining new properties or modifying existing ones easy:\n\n"
 "class C(object):\n"
 "    @property\n"
-"    def x(self): return self._x\n"
+"    def x(self):\n"
+"        \"\I am the 'x' property.\"\n"
+"        return self._x\n"
 "    @x.setter\n"
-"    def x(self, value): self._x = value\n"
+"    def x(self, value):\n"
+"        self._x = value\n"
 "    @x.deleter\n"
-"    def x(self): del self._x\n"
+"    def x(self):\n"
+"        del self._x\n"
 );
 
 static int

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list