Skip to content

Commit 5843de4

Browse files
committed
🎨 Rearrange glossaries
1 parent 32a22af commit 5843de4

File tree

13 files changed

+741
-116
lines changed

13 files changed

+741
-116
lines changed

docs/appendix/glossary.rst

Lines changed: 707 additions & 0 deletions
Large diffs are not rendered by default.

docs/appendix/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ Appendix
44
.. toctree::
55
:titlesonly:
66

7+
glossary
78
checks

docs/control-flow/exceptions.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Exceptions
22
==========
33

4-
This section deals with exceptions, which are language functions that
5-
specifically handle unusual circumstances during the execution of a programme.
6-
The most common exception is error handling, but they can also be used
7-
effectively for many other purposes. Python provides a comprehensive set of
4+
This section deals with :term:`exceptions <exception>`, which are language
5+
functions that specifically handle unusual circumstances during the execution of
6+
a programme. The most common exception is error handling, but they can also be
7+
used effectively for many other purposes. Python provides a comprehensive set of
88
exceptions, and you can define new exceptions for your own purposes.
99

1010
An exception is an object that is automatically created by Python functions with
@@ -90,14 +90,13 @@ Line 19
9090
The way Python handles error situations in general differs from some other
9191
languages, such as Java. These languages check possible errors as far as
9292
possible before they occur, as handling exceptions after they occur is
93-
costly. This is sometimes referred to as the :abbr:`LBYL (Look before you
94-
leap)` approach.
93+
costly. This is sometimes referred to as the :term:`LBYL` approach.
9594

9695
Python, on the other hand, relies more on exceptions to handle errors after
9796
they occur. Although this reliance may seem risky, when exceptions are used
9897
correctly, the code is less cumbersome and easier to read, and errors are
9998
only handled when they occur. This Pythonic approach to error handling is
100-
often described as :abbr:`EAFP (easier to ask forgiveness than permission)`.
99+
often described as :term:`EAFP`.
101100

102101
Checks
103102
------
@@ -117,5 +116,4 @@ Checks
117116
the variable ``x`` is greater or less than ``3``?
118117

119118
* Is the check whether an object is a list (:ref:`Check: list <check-list>`)
120-
programming in the style of :abbr:`LBYL (look before you leap)` or
121-
:abbr:`EAFP (easier to ask forgiveness than permission)`?
119+
programming in the style of :term:`LBYL` or :term:`EAFP`?

docs/control-flow/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Control flow
22
============
33

4-
Python has a whole range of structures for controlling code execution and
5-
programme flow, including common branches and loops:
4+
Python has a whole range of :term:`control flows <Control flow>` to control code
5+
execution and programme flow, including common branches and loops:
66

77
:doc:`boolean`
88
check values and identity and allow links between the two.

docs/functions/params.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Parameters
22
==========
33

4-
Python offers flexible mechanisms for passing arguments to functions:
4+
Python offers flexible mechanisms for passing :term:`arguments <argument>` to
5+
:term:`functions <function>`:
56

67
.. code-block:: pycon
78
:linenos:

docs/oop/methods.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ normal function call by applying the following rules:
101101
``instance.method(arg1, arg2, …)`` becomes
102102
``class.method(instance, arg1, arg2, …)``.
103103

104+
.. _staticmethod:
105+
104106
Static methods
105107
--------------
106108

@@ -128,6 +130,8 @@ Line 14
128130
>>> circle.Circle.circumferences()
129131
12.56636
130132
133+
.. _classmethod:
134+
131135
Class methods
132136
-------------
133137

docs/oop/types.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ Duck typing
119119
The use of :class:`python3:type`, :func:`python3:isinstance` and
120120
:func:`python3:issubclass` makes it fairly easy to correctly determine the
121121
inheritance hierarchy of an object or class. However, Python also has a feature
122-
that makes using objects even easier: duck typing – *If it walks like a duck
123-
and it quacks like a duck, then it must be a duck*. This refers to Python’s way
124-
of determining whether an object is the required type for an operation, focusing
125-
on the interface of an object. In short, in Python you don’t have to worry about
126-
type-checking function or method arguments and the like, but instead rely on
127-
readable and documented code in conjunction with tests to ensure that an object
128-
quacks like a duck when needed.“
122+
that makes using objects even easier: duck typing – *If it looks like a duck,
123+
swims like a duck, and quacks like a duck, then it probably is a duck.’*. This
124+
refers to Python’s way of determining whether an object is the required type for
125+
an operation, focusing on the interface of an object. In short, in Python you
126+
don’t have to worry about type-checking function or method arguments and the
127+
like, but instead rely on readable and documented code in conjunction with tests
128+
to ensure that an object ‘quacks like a duck when needed’.
129129

130130
Duck typing can increase the flexibility of well-written code and, in
131131
combination with advanced object-oriented functions, gives you the ability to

docs/test/glossary.rst

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/test/index.rst

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,9 @@ Basically, a distinction is made between static and dynamic test procedures.
55

66
.. glossary::
77

8-
Static test procedures
9-
are used to check the source code, but it’s not executed. They are divided
10-
into
11-
12-
* :ref:`reviews <code_reviews>` and
13-
* `static program analysis
14-
<https://en.wikipedia.org/wiki/Static_program_analysis>`_
15-
16-
There are several Python packages that can help you with static program
17-
analysis, including :doc:`Python4DataScience:productive/qa/flake8`,
18-
:doc:`Python4DataScience:productive/qa/pysa` and
19-
:doc:`Python4DataScience:productive/qa/wily`.
20-
21-
Dynamic testing
22-
are used to find errors when executing the source code. A distinction is
23-
made between whitebox and backbox tests.
24-
25-
Whitebox tests
26-
are developed with knowledge of the source code and the software
27-
structure. In Python, various modules are available:
28-
29-
:doc:`unittest`
30-
supports you in automating tests.
31-
:doc:`mock`
32-
allows you to create and use mock objects.
33-
:doc:`../document/doctest`
34-
allows you to test tests written in Python docstrings.
35-
:doc:`tox`
36-
allows you to test in different environments.
37-
38-
Blackbox tests
39-
are developed without knowledge of the source code. In addition to
40-
:doc:`unittest`, :doc:`hypothesis` can also be used in Python for such
41-
tests.
8+
.. include:: ../appendix/glossary.rst
9+
:start-after: start-test-procedures:
10+
:end-before: end-test-procedures:
4211

4312
.. tip::
4413
`cusy seminar: Efficient testing with Python
@@ -57,4 +26,3 @@ Basically, a distinction is made between static and dynamic test procedures.
5726
mock
5827
hypothesis
5928
tox
60-
glossary

docs/test/pytest/functions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ If we now run the test with Python, we get the following result:
154154
That doesn’t tell us much. The pytest output gives us much more information
155155
about why our assumptions failed.
156156

157+
.. _pytest_fail:
158+
157159
Failing with ``pytest.fail()`` and exceptions
158160
---------------------------------------------
159161

docs/types/dicts.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Values can be any type of object, including mutable types such as
2121
>>> dict["2022-02-03"] = -0.268295
2222
2323
If you try to access the value of a key that is not contained in the dictionary,
24-
a ``KeyError`` exception is thrown. To avoid this error, the dictionary method
25-
``get`` optionally returns a user-defined value if a key is not contained in a
26-
dictionary.
24+
a ``KeyError`` :doc:`/control-flow/exceptions` is thrown. To avoid this error,
25+
the dictionary method ``get`` optionally returns a user-defined value if a key
26+
is not contained in a dictionary.
2727

2828
.. code-block:: pycon
2929

docs/types/sequences-sets/lists.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ list are to be sorted.
268268

269269
However, the standard key method used by :meth:`python3:list.sort` requires that
270270
all elements in the list are of comparable type. In a list that contains both
271-
numbers and strings, an :class:`python3:Exception` is therefore thrown:
271+
numbers and strings, an :term:`Exception` is therefore thrown:
272272

273273
.. code-block:: pycon
274274

docs/types/strings/print.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ types can easily be converted into strings and formatted, for example:
2121
... )
2222
Pi is 3.141592653589793 and the circumference with a diameter of 28 inches is 87.96459430051421 inches.
2323
24+
.. _f-strings:
25+
2426
F-Strings
2527
---------
2628

0 commit comments

Comments
 (0)