Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge in the main branch
  • Loading branch information
encukou committed Feb 18, 2026
commit 97f8bd00d1dcdc22ecf117166694798a4efeac52
38 changes: 35 additions & 3 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,50 @@ The simplest atoms are :ref:`names <identifiers>` or literals.
Forms enclosed in parentheses, brackets or braces are also categorized
syntactically as atoms.

.. productionlist:: python-grammar
atom: `identifier` | `literal` | `enclosure`
Formally, the syntax for atoms is:

.. grammar-snippet::
:group: python-grammar

atom:
| 'True'
| 'False'
| 'None'
| '...'
| `identifier`
| `literal`
| `enclosure`
enclosure:
| (`group` | `tuple` | `yield_atom` | `generator_expression`) # in (parentheses)
| `list_display`
| `dict_display`
| `set_display`
| `yield_atom`


.. _atom-singletons:

Built-in constants
------------------

The keywords ``True``, ``False``, and ``None`` name
:ref:`built-in constants <built-in-consts>`.
The token ``...`` names the :py:data:`Ellipsis` constant.

Evaluation of these atoms yields the corresponding value.

.. note::

Several more built-in constants are available as global variables,
but only the ones mentioned here are :ref:`keywords <keywords>`.
In particular, these names cannot be reassigned or used as attributes:

.. code-block:: pycon

>>> False = 123
File "<input>", line 1
False = 123
^^^^^
SyntaxError: cannot assign to False

.. _atom-identifiers:

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.