]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)
authorAmmar Askar <ammar@ammaraskar.com>
Fri, 27 Mar 2020 16:37:43 +0000 (09:37 -0700)
committerGitHub <noreply@github.com>
Fri, 27 Mar 2020 16:37:43 +0000 (16:37 +0000)
Doc/whatsnew/3.8.rst

index 09047c460df01c9ec3d74b3ab512e3bbe7753f2a..18fb2e07ed77a2711ffb0a64e73d85d86d0b4324 100644 (file)
@@ -142,12 +142,11 @@ However, these are invalid calls::
 
 One use case for this notation is that it allows pure Python functions
 to fully emulate behaviors of existing C coded functions.  For example,
-the built-in :func:`pow` function does not accept keyword arguments::
+the built-in :func:`divmod` function does not accept keyword arguments::
 
-  def pow(x, y, z=None, /):
-      "Emulate the built in pow() function"
-      r = x ** y
-      return r if z is None else r%z
+  def divmod(a, b, /):
+      "Emulate the built in divmod() function"
+      return (a // b, a % b)
 
 Another use case is to preclude keyword arguments when the parameter
 name is not helpful.  For example, the builtin :func:`len` function has