[Python-checkins] r83548 - python/branches/py3k/Doc/library/functions.rst

georg.brandl python-checkins at python.org
Mon Aug 2 21:23:34 CEST 2010


Author: georg.brandl
Date: Mon Aug  2 21:23:34 2010
New Revision: 83548

Log:
#8172: how does one use a property?

Modified:
   python/branches/py3k/Doc/library/functions.rst

Modified: python/branches/py3k/Doc/library/functions.rst
==============================================================================
--- python/branches/py3k/Doc/library/functions.rst	(original)
+++ python/branches/py3k/Doc/library/functions.rst	Mon Aug  2 21:23:34 2010
@@ -847,7 +847,7 @@
 
    *fget* is a function for getting an attribute value, likewise *fset* is a
    function for setting, and *fdel* a function for del'ing, an attribute.  Typical
-   use is to define a managed attribute x::
+   use is to define a managed attribute ``x``::
 
       class C(object):
           def __init__(self):
@@ -861,6 +861,9 @@
               del self._x
           x = property(getx, setx, delx, "I'm the 'x' property.")
 
+   If then *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. Otherwise, the
    property will copy *fget*'s docstring (if it exists).  This makes it possible to
    create read-only properties easily using :func:`property` as a :term:`decorator`::


More information about the Python-checkins mailing list