diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-06-01 08:00:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 08:00:15 (GMT) |
commit | 2085bd0877e17ad4d98a4586d5eabb6faecbb190 (patch) | |
tree | c25b20d33ebf4d64a28abb8591f4ff7acf90614c /Lib/operator.py | |
parent | 4a686504eb2bbf69adf78077458508a7ba131667 (diff) | |
download | cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.zip cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.gz cpython-2085bd0877e17ad4d98a4586d5eabb6faecbb190.tar.bz2 |
bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)
Diffstat (limited to 'Lib/operator.py')
-rw-r--r-- | Lib/operator.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Lib/operator.py b/Lib/operator.py index 0e2e53e..fb58851 100644 --- a/Lib/operator.py +++ b/Lib/operator.py @@ -302,15 +302,11 @@ class methodcaller: """ __slots__ = ('_name', '_args', '_kwargs') - def __init__(*args, **kwargs): - if len(args) < 2: - msg = "methodcaller needs at least one argument, the method name" - raise TypeError(msg) - self = args[0] - self._name = args[1] + def __init__(self, name, /, *args, **kwargs): + self._name = name if not isinstance(self._name, str): raise TypeError('method name must be a string') - self._args = args[2:] + self._args = args self._kwargs = kwargs def __call__(self, obj): |