bpo-38237: Use divmod for positional arguments whatsnew example (GH-19171)
This commit is contained in:
parent
1c1e68cf3e
commit
5a58c5280b
|
@ -142,12 +142,11 @@ However, these are invalid calls::
|
||||||
|
|
||||||
One use case for this notation is that it allows pure Python functions
|
One use case for this notation is that it allows pure Python functions
|
||||||
to fully emulate behaviors of existing C coded functions. For example,
|
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, /):
|
def divmod(a, b, /):
|
||||||
"Emulate the built in pow() function"
|
"Emulate the built in divmod() function"
|
||||||
r = x ** y
|
return (a // b, a % b)
|
||||||
return r if z is None else r%z
|
|
||||||
|
|
||||||
Another use case is to preclude keyword arguments when the parameter
|
Another use case is to preclude keyword arguments when the parameter
|
||||||
name is not helpful. For example, the builtin :func:`len` function has
|
name is not helpful. For example, the builtin :func:`len` function has
|
||||||
|
|
Loading…
Reference in New Issue