[Python-checkins] r58935 - python/trunk/Objects/descrobject.c
christian.heimes
python-checkins at python.org
Mon Nov 12 02:15:40 CET 2007
Author: christian.heimes
Date: Mon Nov 12 02:15:40 2007
New Revision: 58935
Modified:
python/trunk/Objects/descrobject.c
Log:
Added new decorator syntax to property.__doc__
Guido prefers _x over __x.
Modified: python/trunk/Objects/descrobject.c
==============================================================================
--- python/trunk/Objects/descrobject.c (original)
+++ python/trunk/Objects/descrobject.c Mon Nov 12 02:15:40 2007
@@ -1268,10 +1268,20 @@
"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"
"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.\")");
+" 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 makes defining new or modifying existing properties easy:\n"
+"class C(object):\n"
+" @property\n"
+" def x(self): return self._x\n"
+" @x.setter\n"
+" def x(self, value): self._x = value\n"
+" @x.deleter\n"
+" def x(self): del self._x\n"
+);
static int
property_traverse(PyObject *self, visitproc visit, void *arg)
More information about the Python-checkins
mailing list