8000 bpo-38237: Use divmod for positional arguments whatsnew example (GH-1… · python/cpython@5a58c52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a58c52

Browse files
authored
bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)
1 parent 1c1e68c commit 5a58c52

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Doc/whatsnew/3.8.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,11 @@ However, these are invalid calls::
142142

143143
One use case for this notation is that it allows pure Python functions
144144
to fully emulate behaviors of existing C coded functions. For example,
145-
the built-in :func:`pow` function does not accept keyword arguments::
145+
the built-in :func:`divmod` function does not accept keyword arguments::
146146

147-
def pow(x, y, z=None, /):
148-
"Emulate the built in pow() function"
149-
r = x ** y
150-
return r if z is None else r%z
147+
def divmod(a, b, /):
148+
"Emulate the built in divmod() function"
149+
return (a // b, a % b)
151150

152151
Another use case is to preclude keyword arguments when the parameter
153152
name is not helpful. For example, the builtin :func:`len` function has

0 commit comments

Comments
 (0)
0