]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Replace broken example code with correct simpler code. (GH-25162)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Sat, 3 Apr 2021 20:09:01 +0000 (13:09 -0700)
committerGitHub <noreply@github.com>
Sat, 3 Apr 2021 20:09:01 +0000 (13:09 -0700)
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.

Doc/howto/descriptor.rst

index 819401ea1385c58477d14988e6deee1932b23087..bf026f4b7e61bee2a31b1ed8203480e16b0646d7 100644 (file)
@@ -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*