summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-26 12:42:26 (GMT)
committerGitHub <noreply@github.com>2022-01-26 12:42:26 (GMT)
commita57ec7a4feaf24f470a9d1e5b1b3f2cb1b062af7 (patch)
tree0ae270317667bc78682c1bc56701debf0d5bcab5
parent4371fbd4328781496f5f2c6938c4d9a84049b187 (diff)
downloadcpython-a57ec7a4feaf24f470a9d1e5b1b3f2cb1b062af7.zip
cpython-a57ec7a4feaf24f470a9d1e5b1b3f2cb1b062af7.tar.gz
cpython-a57ec7a4feaf24f470a9d1e5b1b3f2cb1b062af7.tar.bz2
bpo-43698: do not use `...` as argument name in docs (GH-30502)
(cherry picked from commit b9d8980d89bfaa4bf16d60f0488adcc9d2cbf5ef) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r--Doc/faq/design.rst19
-rw-r--r--Doc/glossary.rst4
-rw-r--r--Doc/library/abc.rst10
-rw-r--r--Doc/library/functions.rst2
4 files changed, 16 insertions, 19 deletions
diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst
index 0437b59..ff83a1b 100644
--- a/Doc/faq/design.rst
+++ b/Doc/faq/design.rst
@@ -266,12 +266,9 @@ For cases where you need to choose from a very large number of possibilities,
you can create a dictionary mapping case values to functions to call. For
example::
- def function_1(...):
- ...
-
functions = {'a': function_1,
'b': function_2,
- 'c': self.method_1, ...}
+ 'c': self.method_1}
func = functions[value]
func()
@@ -279,14 +276,14 @@ example::
For calling methods on objects, you can simplify yet further by using the
:func:`getattr` built-in to retrieve methods with a particular name::
- def visit_a(self, ...):
- ...
- ...
+ class MyVisitor:
+ def visit_a(self):
+ ...
- def dispatch(self, value):
- method_name = 'visit_' + str(value)
- method = getattr(self, method_name)
- method()
+ def dispatch(self, value):
+ method_name = 'visit_' + str(value)
+ method = getattr(self, method_name)
+ method()
It's suggested that you use a prefix for the method names, such as ``visit_`` in
this example. Without such a prefix, if values are coming from an untrusted
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 1bbd05a..ddf085b 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -292,12 +292,12 @@ Glossary
The decorator syntax is merely syntactic sugar, the following two
function definitions are semantically equivalent::
- def f(...):
+ def f(arg):
...
f = staticmethod(f)
@staticmethod
- def f(...):
+ def f(arg):
...
The same concept exists for classes, but is less commonly used there. See
diff --git a/Doc/library/abc.rst b/Doc/library/abc.rst
index 1a6ed47..3b74622 100644
--- a/Doc/library/abc.rst
+++ b/Doc/library/abc.rst
@@ -186,15 +186,15 @@ The :mod:`abc` module also provides the following decorator:
class C(ABC):
@abstractmethod
- def my_abstract_method(self, ...):
+ def my_abstract_method(self, arg1):
...
@classmethod
@abstractmethod
- def my_abstract_classmethod(cls, ...):
+ def my_abstract_classmethod(cls, arg2):
...
@staticmethod
@abstractmethod
- def my_abstract_staticmethod(...):
+ def my_abstract_staticmethod(arg3):
...
@property
@@ -255,7 +255,7 @@ The :mod:`abc` module also supports the following legacy decorators:
class C(ABC):
@classmethod
@abstractmethod
- def my_abstract_classmethod(cls, ...):
+ def my_abstract_classmethod(cls, arg):
...
@@ -276,7 +276,7 @@ The :mod:`abc` module also supports the following legacy decorators:
class C(ABC):
@staticmethod
@abstractmethod
- def my_abstract_staticmethod(...):
+ def my_abstract_staticmethod(arg):
...
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 9a9c87e..9523136 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -248,7 +248,7 @@ are always available. They are listed here in alphabetical order.
class C:
@classmethod
- def f(cls, arg1, arg2, ...): ...
+ def f(cls, arg1, arg2): ...
The ``@classmethod`` form is a function :term:`decorator` -- see
:ref:`function` for details.