]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#8172: how does one use a property?
authorGeorg Brandl <georg@python.org>
Mon, 2 Aug 2010 19:23:34 +0000 (19:23 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 2 Aug 2010 19:23:34 +0000 (19:23 +0000)
Doc/library/functions.rst

index 5c21f34a3f1327cd9697b9e8edd0a6921e161b4d..5fb4f7024034b97e418c368b55587e57585a562c 100644 (file)
@@ -847,7 +847,7 @@ are always available.  They are listed here in alphabetical order.
 
    *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 @@ are always available.  They are listed here in alphabetical order.
               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`::