Skip to content

Commit e43b7e5

Browse files
committed
✏️ Fix typos and reST syntax
1 parent 343775e commit e43b7e5

32 files changed

+261
-242
lines changed

docs/appendix/checks.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ Checks
998998
>>> print(new_path)
999999
/Users/veit/python-basics-tutorial-de/example.log2
10001000
1001-
* What is the significance of adding ``b`` as a parameter to
1001+
* What is the significance of adding ``b`` as a :term:`parameter` to
10021002
:func:`python3:open`?
10031003

10041004
This opens the file in binary mode, which means that bytes and not characters

docs/appendix/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ Glossary
675675

676676
Dummy
677677
Object that is passed around but never actually used. Normally dummies
678-
are only used to fill parameter lists.
678+
are only used to fill :term:`parameter` lists.
679679

680680
``except``
681681
Keyword used to intercept an :term:`exception` and handle it carefully.

docs/functions/decorators.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Decorators
33

44
Functions can also be passed as arguments to other functions and return the
55
results of other functions. For example, it is possible to write a Python
6-
function that takes another function as a parameter, embeds it in another
7-
function that does something similar, and then returns the new function. This
8-
new combination can then be used instead of the original function:
6+
function that takes another function as a :term:`parameter`, embeds it in
7+
another function that does something similar, and then returns the new function.
8+
This new combination can then be used instead of the original function:
99

1010
.. code-block:: pycon
1111
:linenos:
@@ -41,8 +41,8 @@ much cleaner and easier to read. Using a decorator simply consists of two parts:
4141
#. the use of an ``@`` followed by the decorator just before the wrapped
4242
function is defined.
4343

44-
The decorator function should take a function as a parameter and return a
45-
function, as follows:
44+
The decorator function should take a function as a :term:`parameter` and return
45+
a function, as follows:
4646

4747
.. code-block:: pycon
4848
:linenos:
@@ -71,9 +71,9 @@ as decorators, such as:
7171
:func:`functools.cache`
7272
Simple, lightweight, function cache as of Python ≥ 3.9, sometimes called
7373
*memoize*. It returns the same as :func:`functools.lru_cache` with the
74-
parameter ``maxsize=None``, additionally creating a :doc:`/types/dicts` with
75-
the function arguments. Since old values never need to be deleted, this
76-
function is then also smaller and faster. Example:
74+
:term:`parameter` ``maxsize=None``, additionally creating a
75+
:doc:`/types/dicts` with the function arguments. Since old values never
76+
need to be deleted, this function is then also smaller and faster. Example:
7777

7878
.. code-block:: pycon
7979
:linenos:

docs/functions/index.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ inserts the code into a function so that you can call it to get the `factorial
3030
Line 2
3131
This is an optional documentation string, or ``docstring``. You can get its
3232
value by calling ``fact.__doc__``. The purpose of docstrings is to describe
33-
the behaviour of a function and the parameters it takes, while comments are
34-
to document internal information about how the code works. Docstrings are
35-
:doc:`/types/strings/index` that immediately follow the first line of a
36-
function definition and are usually enclosed in triple quotes to allow for
37-
multi-line descriptions. For multi-line documentation strings, it is common
38-
to give a summary of the function on the first line, follow this summary
39-
with an empty line and end with the rest of the information.
33+
the behaviour of a function and the :term:`parameters <Parameter>` it takes,
34+
while comments are to document internal information about how the code
35+
works. Docstrings are :doc:`/types/strings/index` that immediately follow
36+
the first line of a function definition and are usually enclosed in triple
37+
quotes to allow for multi-line descriptions. For multi-line documentation
38+
strings, it is common to give a summary of the function on the first line,
39+
follow this summary with an empty line and end with the rest of the
40+
information.
4041

4142
.. seealso::
4243
* :ref:`napoleon`

docs/functions/params.rst

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,30 @@ Line 11
4747
Function arguments can be entered either by position or by name (keyword).
4848
``z`` and ``y`` are specified by name in our example.
4949
Line 13
50-
Function parameters can be defined with default values that will be used if
51-
a function call omits them.
50+
Function :term:`parameters <Parameter>` can be defined with default values
51+
that will be used if a function call omits them.
5252
Line 18
53-
A special parameter can be defined that combines all additional positional
54-
arguments in a function call into one tuple.
53+
A special :term:`parameter` can be defined that combines all additional
54+
positional arguments in a function call into one tuple.
5555
Line 25
56-
Similarly, a special parameter can be defined that summarises all additional
57-
keyword arguments in a function call in a dictionary.
56+
Similarly, a special :term:`parameter` can be defined that summarises all
57+
additional keyword arguments in a function call in a dictionary.
5858

5959
Options for function parameters
6060
-------------------------------
6161

62-
Most functions need parameters. Python offers three options for defining
63-
function parameters.
62+
Most functions need :term:`parameters <Parameter>`. Python offers three options
63+
for defining function parameters.
6464

6565
Positional parameters
6666
~~~~~~~~~~~~~~~~~~~~~
6767

68-
The simplest way to pass parameters to a function in Python is to pass them at
69-
the position. On the first line of the function, you specify the variable name
70-
for each parameter; when the function is called, the parameters used in the
71-
calling code are assigned to the function’s parameter variables based on their
72-
order. The following function calculates ``x`` as a power of ``y``:
68+
The simplest way to pass :term:`parameters <Parameter>` to a function in Python
69+
is to pass them at the position. On the first line of the function, you specify
70+
the variable name for each parameter; when the function is called, the
71+
parameters used in the calling code are assigned to the function’s parameter
72+
variables based on their order. The following function calculates ``x`` as a
73+
power of ``y``:
7374

7475
.. code-block:: pycon
7576
@@ -83,9 +84,9 @@ order. The following function calculates ``x`` as a power of ``y``:
8384
>>> power(2, 5)
8485
32
8586
86-
This method requires that the number of parameters used by the calling code
87-
exactly matches the number of parameters in the function definition; otherwise,
88-
a type error exception is thrown:
87+
This method requires that the number of :term:`parameters <Parameter>` used by
88+
the calling code exactly matches the number of parameters in the function
89+
definition; otherwise, a type error exception is thrown:
8990

9091
.. code-block:: pycon
9192
@@ -94,15 +95,17 @@ a type error exception is thrown:
9495
File "<stdin>", line 1, in <module>
9596
TypeError: power() missing 1 required positional argument: 'y'
9697
97-
Function parameters can have default values, which you can declare by assigning
98-
a default value in the first line of the function definition, like this:
98+
Function :term:`parameters <Parameter>` can have default values, which you can
99+
declare by assigning a default value in the first line of the function
100+
definition, like this:
99101

100102
.. code-block:: pycon
101103
102104
def function_name(param1, param2=Standardwert2, param3=Standardwert3, ...)
103105
104-
Any number of parameters can be given default values, but parameters with
105-
default values must be defined as the last in the parameter list.
106+
Any number of :term:`parameters <Parameter>` can be given default values, but
107+
parameters with default values must be defined as the last in the parameter
108+
list.
106109

107110
The following function also calculates ``x`` as a power of ``y``. However, if
108111
``y`` is not specified in a function call, the default value ``5`` is used:
@@ -130,7 +133,7 @@ Parameter names
130133
~~~~~~~~~~~~~~~
131134

132135
You can also pass arguments to a function by using the name of the corresponding
133-
function parameter rather than its position. Similar to the previous example,
136+
function :term:`parameter` rather than its position. Similar to the previous example,
134137
you can enter the following:
135138

136139
.. code-block:: pycon
@@ -139,12 +142,12 @@ you can enter the following:
139142
64
140143
141144
Since the arguments for the power are named ``x`` and ``y`` in the last call,
142-
their order is irrelevant; the arguments are linked to the parameters of the
143-
same name in the definition of the power, and you get back ``2^6``. This type of
144-
argument passing is called keyword passing. Keyword passing can be very useful
145-
in combination with the default arguments of Python functions when you define
146-
functions with a large number of possible arguments, most of which have common
147-
default values.
145+
their order is irrelevant; the arguments are linked to the :term:`parameters
146+
<Parameter>` of the same name in the definition of the power, and you get back
147+
``2^6``. This type of argument passing is called keyword passing. Keyword
148+
passing can be very useful in combination with the default arguments of Python
149+
functions when you define functions with a large number of possible arguments,
150+
most of which have common default values.
148151

149152
Variable number of arguments
150153
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -153,14 +156,15 @@ Python functions can also be defined to handle a variable number of arguments.
153156
This is possible in two ways. One method collects an unknown number of arguments
154157
in a :doc:`list </types/sequences-sets/lists>`. The other method can collect an
155158
arbitrary number of arguments passed with a keyword that has no correspondingly
156-
named parameter in the function parameter list in a :doc:`dict </types/dicts>`.
159+
named :term:`parameter` in the function parameter list in a :doc:`dict
160+
</types/dicts>`.
157161

158162
For an indeterminate number of positional arguments, prefixing the function’s
159-
final parameter name with a ``*`` causes all excess non-keyword arguments in a
160-
function call, that is, the positional arguments that are not assigned to any
161-
other parameter, to be collected and assigned as a tuple to the specified
162-
parameter. This is, for example, a simple way to implement a function that finds
163-
the mean in a list of numbers:
163+
final :term:`parameter` name with a ``*`` causes all excess non-keyword
164+
arguments in a function call, that is, the positional arguments that are not
165+
assigned to any other parameter, to be collected and assigned as a tuple to the
166+
specified parameter. This is, for example, a simple way to implement a function
167+
that finds the mean in a list of numbers:
164168

165169
.. code-block:: pycon
166170
@@ -179,13 +183,14 @@ Now you can test the behaviour of the function, for example with:
179183
>>> mean(3, 5, 2, 4, 6)
180184
4.0
181185
182-
Any number of keyword arguments can also be processed if the last parameter in
183-
the parameter list is prefixed with ``**``. Then all arguments passed with a
184-
keyword are collected in a :doc:`dict </types/dicts>`. The key for each entry in
185-
the dict is the keyword (parameter name) for the argument. The value of this
186-
entry is the argument itself. An argument passed by keyword is superfluous in
187-
this context if the keyword with which it was passed does not match one of the
188-
parameter names in the function definition, for example:
186+
Any number of keyword arguments can also be processed if the last
187+
:term:`parameter` in the parameter list is prefixed with ``**``. Then all
188+
arguments passed with a keyword are collected in a :doc:`dict </types/dicts>`.
189+
The key for each entry in the dict is the keyword (parameter name) for the
190+
argument. The value of this entry is the argument itself. An argument passed by
191+
keyword is superfluous in this context if the keyword with which it was passed
192+
does not match one of the parameter names in the function definition, for
193+
example:
189194

190195
.. code-block:: pycon
191196
@@ -203,7 +208,7 @@ parameter names in the function definition, for example:
203208
204209
Trying out this function shows that it can add the arguments passed under the
205210
keywords ``foo``, ``bar`` and ``baz``, even though ``foo``, ``bar`` and ``baz``
206-
are not parameter names in the function definition:
211+
are not :term:`parameter` names in the function definition:
207212

208213
.. code-block:: pycon
209214
@@ -223,11 +228,11 @@ keyword arguments with ``**``.
223228
Mutable objects as arguments
224229
----------------------------
225230

226-
Arguments are passed by object reference. The parameter becomes a new reference
227-
to the object. With :term:`immutable` objects such as
231+
Arguments are passed by object reference. The :term:`parameter` becomes a new
232+
reference to the object. With :term:`immutable` objects such as
228233
:doc:`/types/sequences-sets/tuples`, :doc:`/types/strings/index` and
229-
:doc:`/types/numbers/index`, what is done with a parameter has no effect
230-
outside the function. However, if you pass a mutable object, such as a
234+
:doc:`/types/numbers/index`, what is done with a parameter has no effect outside
235+
the function. However, if you pass a mutable object, such as a
231236
:doc:`/types/sequences-sets/lists`, a :doc:`/types/dicts` or a class instance,
232237
any change to the object changes what the argument refers to outside the
233238
function. Reassigning the parameter has no effect on the argument.
@@ -245,9 +250,9 @@ function. Reassigning the parameter has no effect on the argument.
245250
(5, [2, 4, 6, 1])
246251
247252
The variable ``x`` is not changed because it is :term:`immutable`. Instead, the
248-
function parameter ``n`` is set so that it refers to the new value ``6``.
249-
However, there is a change in ``y`` because the list it refers to has been
250-
changed.
253+
function :term:`parameter` ``n`` is set so that it refers to the new value
254+
``6``. However, there is a change in ``y`` because the list it refers to has
255+
been changed.
251256

252257
Checks
253258
------

docs/functions/variables.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Here you return to the definition of ``fact`` from the beginning of this
2121
2222
Both the variables ``f`` and ``n`` are local to a particular call to the
2323
function ``fact``; changes made to them during the execution of the function
24-
have no effect on variables outside the function. All variables in the parameter
25-
list of a function and all variables created within a function by an assignment,
26-
such as ``f = 1``, are local to the function:
24+
have no effect on variables outside the function. All variables in the
25+
:term:`parameter` list of a function and all variables created within a function
26+
by an assignment, such as ``f = 1``, are local to the function:
2727

2828
.. code-block:: pycon
2929

docs/libs/batteries.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Modules for data types
5656
| :py:mod:`pprint` | prints Python data structures „pretty“. |
5757
+-----------------------+-------------------------------------------------------------------------------+
5858
| :py:mod:`typing` | supports commenting code with hints about the types of objects, especially |
59-
| | function parameters and return values |
59+
| | function :term:`parameters <Parameter>` and return values |
6060
+-----------------------+-------------------------------------------------------------------------------+
6161

6262
Modules for numbers
@@ -175,7 +175,7 @@ Developing and debugging
175175
| :py:mod:`profile`, | Python profiler |
176176
| :py:mod:`cProfile` | |
177177
+-----------------------------------+-------------------------------------------------------------------------------+
178-
| :py:mod:`sys` | System-specific parameters and functions |
178+
| :py:mod:`sys` | System-specific :term:`parameters <Parameter>` and functions |
179179
+-----------------------------------+-------------------------------------------------------------------------------+
180180
| :py:mod:`gc` | Functions of the Python garbage collector |
181181
+-----------------------------------+-------------------------------------------------------------------------------+

docs/oop/coherent.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ Python. I will now illustrate these basics in a coherent example:
1515

1616
Line 7
1717
The ``__init__`` method requires one instance (``self``) and two
18-
parameters.
18+
:term:`parameters <Parameter>`.
1919
Lines 8 and 9
2020
The two instance variables ``x`` and ``y``, which are accessed via
2121
``self``.
2222
Line 10
23-
The ``move`` method requires one instance (``self``) and two parameters.
23+
The ``move`` method requires one instance (``self``) and two
24+
:term:`parameters <Parameter>`.
2425
Lines 11 and 12
2526
Instance variables that are set in the ``move`` method.
2627

@@ -36,7 +37,7 @@ Python. I will now illustrate these basics in a coherent example:
3637
The class ``Square`` inherits from the class ``Form``.
3738
Line 19
3839
``Square``’s ``__init__`` takes one instance (``self``) and three
39-
parameters, all with defaults.
40+
:term:`parameters <Parameter>`, all with defaults.
4041
Line 20
4142
``Square``’s ``__init__`` uses ``super()`` to call ``Form``’s
4243
``__init__``.
@@ -56,13 +57,14 @@ Python. I will now illustrate these basics in a coherent example:
5657
``circles`` list.
5758
Lines 37 and 38
5859
``circumferences`` is a class method and takes the class itself
59-
(``cls``) as a parameter.
60+
(``cls``) as a :term:`parameter`.
6061
Line 41
61-
uses the parameter ``cls`` to access the class variable ``circles``.
62+
uses the :term:`parameter` ``cls`` to access the class variable
63+
``circles``.
6264

6365
Now you can create some instances of the class ``Circle`` and analyse them.
64-
Since the ``__init__`` method of ``Circle`` has default parameters, you can
65-
create a circle without specifying any parameters:
66+
Since the ``__init__`` method of ``Circle`` has default :term:`parameters
67+
<Parameter>`, you can create a circle without specifying any parameters:
6668

6769
.. code-block:: pycon
6870
@@ -71,7 +73,8 @@ create a circle without specifying any parameters:
7173
>>> c1.diameter, c1.x, c1.y
7274
(1, 0, 0)
7375
74-
If you specify parameters, they are used to set the values of the instance:
76+
If you specify :term:`parameters <Parameter>`, they are used to set the values
77+
of the instance:
7578

7679
.. code-block:: pycon
7780

docs/oop/inheritance.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ another method in the ``Form`` class called ``move`` that moves a shape in the
102102
... self.diameter = diameter
103103
...
104104

105-
If you take the parameters ``delta_x`` and ``delta_y`` of the method ``move`` in
106-
the ``__init__`` methods of ``Circle`` and ``Square``, you can for example
107-
execute the following interactive session:
105+
If you take the :term:`parameters <Parameter>` ``delta_x`` and ``delta_y`` of
106+
the method ``move`` in the ``__init__`` methods of ``Circle`` and ``Square``,
107+
you can for example execute the following interactive session:
108108

109109
.. code-block:: pycon
110110

docs/oop/methods.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ to set the edge length after creating a square:
5959
``self.length`` and ``length`` are not the same!
6060

6161
* ``self.length`` is the instance variable called ``length``
62-
* ``length`` is the local function parameter
62+
* ``length`` is the local function :term:`parameter`
6363

64-
In practice, you would probably refer to the local function parameter as
65-
``lng`` or ``l`` to avoid confusion.
64+
In practice, you would probably refer to the local function
65+
:term:`parameter` as ``lng`` or ``l`` to avoid confusion.
6666

6767
With this definition of ``Square``, you can create squares with arbitrary edge
6868
lengths with a call to the ``Square`` class. In the following, a square with
@@ -138,7 +138,7 @@ Class methods
138138
:func:`Class methods <classmethod>` are similar to static methods in that they
139139
can be called before an object of the class has been instantiated. However, the
140140
class to which they belong is implicitly passed to the class methods as the
141-
first parameter:
141+
first :term:`parameter`:
142142

143143
.. literalinclude:: circle_cm.py
144144
:language: python
@@ -149,7 +149,7 @@ first parameter:
149149
Line 23
150150
The ``@classmethod`` decorator is used before the ``def`` method.
151151
Line 24
152-
The class parameter is traditionally ``cls``.
152+
The class :term:`parameter` is traditionally ``cls``.
153153
Line 27
154154
You can use ``cls`` instead of ``self.__class__``.
155155

0 commit comments

Comments
 (0)