summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAntony Lee <anntzer.lee@gmail.com>2021-09-24 15:22:49 (GMT)
committerGitHub <noreply@github.com>2021-09-24 15:22:49 (GMT)
commit6587fc60d447603fb8c631d81d9bb379f53c39ab (patch)
treec52c3172f8845e2cb51eed4338436c9e6f58965a /Doc
parent8d8729146f21f61af66e70d3ae9501ea6bdccd09 (diff)
downloadcpython-6587fc60d447603fb8c631d81d9bb379f53c39ab.zip
cpython-6587fc60d447603fb8c631d81d9bb379f53c39ab.tar.gz
cpython-6587fc60d447603fb8c631d81d9bb379f53c39ab.tar.bz2
bpo-44019: Implement operator.call(). (GH-27888)
Having `operator.call(obj, arg)` mean `type(obj).__call__(obj, arg)` is consistent with the other dunder operators. The semantics with `*args, **kwargs` then follow naturally from the single-arg semantics.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/operator.rst11
-rw-r--r--Doc/whatsnew/3.11.rst8
2 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst
index 0cdba68..146cabc 100644
--- a/Doc/library/operator.rst
+++ b/Doc/library/operator.rst
@@ -250,6 +250,17 @@ Operations which work with sequences (some of them with mappings too) include:
.. versionadded:: 3.4
+
+The following operation works with callables:
+
+.. function:: call(obj, / *args, **kwargs)
+ __call__(obj, /, *args, **kwargs)
+
+ Return ``obj(*args, **kwargs)``.
+
+ .. versionadded:: 3.11
+
+
The :mod:`operator` module also defines tools for generalized attribute and item
lookups. These are useful for making fast field extractors as arguments for
:func:`map`, :func:`sorted`, :meth:`itertools.groupby`, or other functions that
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 7e041f2..0e56b46 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -205,6 +205,14 @@ math
Dickinson in :issue:`44339`.)
+operator
+--------
+
+* A new function ``operator.call`` has been added, such that
+ ``operator.call(obj, *args, **kwargs) == obj(*args, **kwargs)``.
+ (Contributed by Antony Lee in :issue:`44019`.)
+
+
os
--