[Python-checkins] bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)

Miss Islington (bot) webhook-mailer at python.org
Fri Mar 27 12:45:10 EDT 2020


https://github.com/python/cpython/commit/9c5c497ac167b843089553f6f62437d263382e97
commit: 9c5c497ac167b843089553f6f62437d263382e97
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-03-27T09:45:05-07:00
summary:

bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)

(cherry picked from commit 5a58c5280b8df4ca5d6a19892b24fff96e9ea868)

Co-authored-by: Ammar Askar <ammar at ammaraskar.com>

files:
M Doc/whatsnew/3.8.rst

diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 3ef97c98ca907..a7abdf0252e5b 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -144,12 +144,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



More information about the Python-checkins mailing list