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
@@ -1354,9 +1368,10 @@ Using the non-data descriptor protocol, a pure Python version of
1354
1368
"A doc for 'T'"
1355
1369
1356
1370
1357
- The code path for ``hasattr(obj, '__get__') `` was added in Python 3.9 and
1358
- makes it possible for :func: `classmethod ` to support chained decorators.
1359
- For example, a classmethod and property could be chained together:
1371
+ The code path for ``hasattr(type(self.f), '__get__') `` was added in
1372
+ Python 3.9 and makes it possible for :func: `classmethod ` to support
1373
+ chained decorators. For example, a classmethod and property could be
1374
+ chained together:
1360
1375
1361
1376
.. testcode ::
1362
1377
You can’t perform that action at this time.
0 commit comments