Skip to content

Commit b37c994

Browse files
authored
bpo-42086: Document AST operator nodes acts as a singleton (GH-22896)
Automerge-Triggered-By: GH:gvanrossum
1 parent b52432c commit b37c994

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/ast.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,13 @@ Async and await
15031503
fields as :class:`For` and :class:`With`, respectively. Only valid in the
15041504
body of an :class:`AsyncFunctionDef`.
15051505

1506+
.. note::
1507+
When a string is parsed by :func:`ast.parse`, operator nodes (subclasses
1508+
of :class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`,
1509+
:class:`ast.boolop` and :class:`ast.expr_context`) on the returned tree
1510+
will be singletons. Changes to one will be reflected in all other
1511+
occurrences of the same value (e.g. :class:`ast.Add`).
1512+
15061513

15071514
:mod:`ast` Helpers
15081515
------------------

0 commit comments

Comments
 (0)