summaryrefslogtreecommitdiffstats
path: root/docs/docsite/rst/dev_guide/testing/sanity/no-underscore-variable.rst
blob: 5174a43adf7d47179dd840dcdfe077e09ef4af57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
:orphan:

no-underscore-variable
======================

In the future, Ansible may use the identifier ``_`` to internationalize its
message strings.  To be ready for that, we need to make sure that there are
no conflicting identifiers defined in the code base.

In common practice, ``_`` is frequently used as a dummy variable (a variable
to receive a value from a function where the value is useless and never used).
In Ansible, we're using the identifier ``dummy`` for this purpose instead.

Example of unfixed code:

.. code-block:: python

    for _ in range(0, retries):
        success = retry_thing()
        if success:
            break

Example of fixed code:

.. code-block:: python

    for dummy in range(0, retries):
        success = retry_thing()
        if success:
            break