Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ updates:
directory: /
schedule:
interval: monthly
cooldown:
default-days: 10
groups:
github-actions:
patterns:
- "*"
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
- uses: actions/cache@v4
- uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
Expand All @@ -21,7 +21,7 @@ jobs:
name: Build docs and check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: pandoc/actions/setup@v1
- uses: actions/setup-python@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: Install packages
run: sudo apt install plantuml
- name: Setup pandoc
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ repos:
- id: check-added-large-files
args: ['--maxkb=1024']
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.7.0
rev: v2.16.2
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.24.1
rev: v0.25
hooks:
- id: validate-pyproject
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
rev: v1.0.2
hooks:
- id: sphinx-lint
types: [rst]
- repo: https://github.com/pycqa/isort
rev: 7.0.0
rev: 8.0.1
hooks:
- id: isort
additional_dependencies: ["toml"]
entry: isort --profile=black
name: isort (python)
- repo: https://github.com/psf/black
rev: 25.9.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.13
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
os: ubuntu-24.04
apt_packages:
# plantuml is required for sphinxcontrib.plantuml
- plantuml
tools:
python: "3.12"
python: "3.13"
jobs:
install:
- python -m pip install --upgrade pip
Expand Down
28 changes: 12 additions & 16 deletions docs/appendix/checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ Checks

.. code-block:: pycon

>>> sheet = {}
>>> sheet[("A", 0)] = 1
>>> sheet[("A", 1)] = 2
>>> sheet[("B", 0)] = 3
>>> sheet[("B", 1)] = 4
>>> print(sheet[("A", 1)])
>>> tabular = {}
>>> tabular[("A", 0)] = 1
>>> tabular[("A", 1)] = 2
>>> tabular[("B", 0)] = 3
>>> tabular[("B", 1)] = 4
>>> print(tabular[("A", 1)])
2

* How can you remove all duplicates from a list without changing the order of the
Expand Down Expand Up @@ -501,7 +501,7 @@ Checks
>>> pos
[0, 1, 2, 3]

* How would you count the total number of negative numbers in the list ``[-[1,
* How would you count the total number of negative numbers in the list ``[[-1,
0, 1], [-1, 1, 3], [-2, 0, 2]]``?

.. code-block:: pycon
Expand Down Expand Up @@ -621,15 +621,11 @@ Checks

.. code-block:: pycon

>> def my_func(*params):
... for i in reversed(params):
... print(i)
...
>>> my_func(1, 2, 3, 4)
4
3
2
1
>>> values = input("Values separated by commas: ")
Values separated by commas: 1,3,2,4
>>> value_list = values.split(",")
>>> reverse(value_list)
['4', '3', '2', '1']

:doc:`/functions/variables`
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
plantuml_output_format = "svg"

intersphinx_mapping = {
"python3": ("https://docs.python.org/3/", None),
"python3": ("https://docs.python.org/3.15/", None),
"python3.14": ("https://docs.python.org/3.14/", None),
"jupyter-tutorial": ("https://jupyter-tutorial.readthedocs.io/en/latest/", None),
"Python4DataScience": ("https://www.python4data.science/en/latest/", None),
Expand Down
52 changes: 41 additions & 11 deletions docs/control-flow/boolean.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,49 @@ considered ``True``.
>>> x == y
True

However, you should never compare calculated floating point numbers with
each other:
.. warning::
However, you should never directly compare calculated floating point
numbers:

.. code-block:: pycon
.. code-block:: pycon

>>> u = 0.6 * 7
>>> v = 0.7 * 6
>>> u == v
False
>>> u
4.2
>>> v
4.199999999999999
>>> u = 0.6 * 7
>>> v = 0.7 * 6
>>> u == v
False
>>> u
4.2
>>> v
4.199999999999999

Instead, you can use :func:`math.isclose`:

.. code-block:: pycon

>>> import math
>>> math.isclose(u, v)
True

Alternatively, you can also use :func:`round`:

.. code-block:: pycon

>>> round(u, 2) == round(v, 2)
True

.. warning::
Integers smaller than -5 or larger than 256 are recreated each time, but
integers in between are pre-instantiated by the interpreter and reused.
Therefore, :py:func:`id` should not be used for comparisons of integers:

.. code-block:: pycon

>>> x = 256
>>> y = 257
>>> id(x) == id(256)
True
>>> id(y) == id(257)
False

``is``, ``is not``, ``in``, ``not in``
checks the identity:
Expand Down
63 changes: 57 additions & 6 deletions docs/control-flow/loops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,24 @@ flow control is continued with ``x`` being set to the next entry in the list.
After the first matching integer is found, the loop is terminated with the
``break`` statement.

Loops with an index
-------------------
``for`` Loops with an index
~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also output the index in a ``for`` loop, for example with
:py:func:`enumerate()`:

.. code-block:: pycon

>>> data_types = ["Data types", "Numbers", "Lists"]
>>> for index, title in enumerate(data_types):
... print(index, title)
>>> for key, title in enumerate(data_types):
... print(key, title)
...
0 Data types
1 Numbers
2 Lists

List Comprehensions
-------------------
~~~~~~~~~~~~~~~~~~~

A list is usually generated as follows:

Expand Down Expand Up @@ -153,14 +153,65 @@ appended to the end of the expression:
>>> squares
[16, 25, 36, 49]

Dict Comprehensions
~~~~~~~~~~~~~~~~~~~

:doc:`../types/sequences-sets/lists` can be converted into :doc:`../types/dicts`
as follows:

.. code-block:: pycon

>>> toc = {}
>>> for key, title in enumerate(data_types):
... toc[key] = title
...
>>> toc
{0: 'Data types', 1: 'Numbers', 2: 'Lists'}

Mit Dict Comprehensions vereinfacht sich dies:

.. code-block:: pycon

>>> toc = {key: value for key, value in enumerate(data_types)}
>>> toc
{0: 'Data types', 1: 'Numbers', 2: 'Lists'}

Das allgemeine Format für Dict Comprehensions ist:

:samp:`{NEW_DICT} = \{{KEY}: {VALUE} for {MEMBER} in {ITERABLE}\}`

Change a ``Collection``
~~~~~~~~~~~~~~~~~~~~~~~

Modifying a ``collection`` while iterating over it can be difficult. Therefore,
a copy of the ``collection`` is often modified instead:

.. code-block:: pycon

>>> for key, title in data_types.items():
... if key == 0:
... del data_types[key]
...
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
for key, title in data_types.items():
~~~~~~~~~~~~~~~~^^
RuntimeError: dictionary changed size during iteration
>>> for key, title in data_types.copy().items():
... if key == 0:
... del data_types[key]
...
>>> data_types
{1: 'Numbers', 2: 'Lists'}

Checks
------

* Removes all negative numbers from the list ``x = [ -2, -1, 0, 1, 2, 3]``.

* Which list comprehension would you use to achieve the same result?

* How would you count the total number of negative numbers in the list ``[-[1,
* How would you count the total number of negative numbers in the list ``[[-1,
0, 1], [-1, 1, 3], [-2, 0, 2]]``?

* Creates a generator that only returns odd numbers from 1 to 10.
Expand Down
14 changes: 8 additions & 6 deletions docs/document/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ describes how your software can be installed, operated, used and improved:
* Those who want to use your package need information,

* what problems your software solves and what the main features and
limitations of the software are (``README``)
limitations of the software are (→ :ref:`readme`)
* how the software can be used as an example
* what changes have come in more recent software versions (``CHANGELOG``)
* what changes have come in more recent software versions (→ :ref:`changelog`)

* Those who want to run the software need an installation guide for your
software and the required dependencies.

* Those who want to improve the software need information about

* how to help improve the product with bug fixes (``CONTRIBUTING``)
* how to communicate with others (``CODE_OF_CONDUCT``)
* how to help improve the product with bug fixes (→ :ref:`contributing`)
* how to report security vulnerabilities (→ :ref:`security`)
* how to communicate with others (→ :ref:`coc`)

All together need information on how the product is licensed (``LICENSE`` file
or ``LICENSES`` folder) and how to get help if needed.
All together need information on how the product is licensed (:file:`LICENSE`
file or :file:`LICENSES` folder, → :ref:`license`) and how to get help if
needed.

.. tip::
cusy seminars:
Expand Down
Loading
Loading