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``:
953
953
def delx(self): del self.__x
954
954
x = property(getx, setx, delx, "I'm the 'x' property.")
955
955
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
+
956
970
To see how :func: `property ` is implemented in terms of the descriptor protocol,
957
971
here is a pure Python equivalent:
958
972
@@ -1364,9 +1378,10 @@ Using the non-data descriptor protocol, a pure Python version of
1364
1378
"A doc for 'T'"
1365
1379
1366
1380
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:
1370
1385
1371
1386
.. testcode ::
1372
1387
You can’t perform that action at this time.
0 commit comments