summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2021-04-03 20:09:01 (GMT)
committerGitHub <noreply@github.com>2021-04-03 20:09:01 (GMT)
commitc5354c045c1067549554c35485a12afdcf88a202 (patch)
tree201b138df94533476c5c2b5b44a4180f4c119d10
parente4c8895ee5457b11f52841b79b51f3c3d6373fef (diff)
downloadcpython-c5354c045c1067549554c35485a12afdcf88a202.zip
cpython-c5354c045c1067549554c35485a12afdcf88a202.tar.gz
cpython-c5354c045c1067549554c35485a12afdcf88a202.tar.bz2
Replace broken example code with correct simpler code. (GH-25162)
The open() was missing 'w' to indicate it was in a write-mode. Even then, the open().close() operation was distracting because it is an unusual way to "touch" as file. Using os.remove() instead is simpler and less distracting.
-rw-r--r--Doc/howto/descriptor.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst
index 819401e..bf026f4 100644
--- a/Doc/howto/descriptor.rst
+++ b/Doc/howto/descriptor.rst
@@ -115,9 +115,9 @@ different, updated answers each time::
20
>>> g.size # The games directory has three files
3
- >>> open('games/newfile').close() # Add a fourth file to the directory
+ >>> os.remove('games/chess') # Delete a game
>>> g.size # File count is automatically updated
- 4
+ 2
Besides showing how descriptors can run computations, this example also
reveals the purpose of the parameters to :meth:`__get__`. The *self*