File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -953,6 +953,20 @@ The documentation shows a typical use to define a managed attribute ``x``:
953953 def delx(self): del self.__x
954954 x = property(getx, setx, delx, "I'm the 'x' property.")
955955
956+ .. doctest ::
957+ :hide:
958+
959+ >>> C.x.__doc__
960+ "I'm the 'x' property."
961+ >>> c.x = 2.71828
962+ >>> c.x
963+ 2.71828
964+ >>> del c.x
965+ >>> c.x
966+ Traceback (most recent call last):
967+ ...
968+ AttributeError: 'C' object has no attribute '_C__x'
969+
956970To see how :func: `property ` is implemented in terms of the descriptor protocol,
957971here is a pure Python equivalent:
958972
@@ -1364,9 +1378,10 @@ Using the non-data descriptor protocol, a pure Python version of
13641378 "A doc for 'T'"
13651379
13661380
1367- The code path for ``hasattr(obj, '__get__') `` was added in Python 3.9 and
1368- makes it possible for :func: `classmethod ` to support chained decorators.
1369- For example, a classmethod and property could be chained together:
1381+ The code path for ``hasattr(type(self.f), '__get__') `` was added in
1382+ Python 3.9 and makes it possible for :func: `classmethod ` to support
1383+ chained decorators. For example, a classmethod and property could be
1384+ chained together:
13701385
13711386.. testcode ::
13721387
You can’t perform that action at this time.
0 commit comments