Python Glossary Русский

all Python 3deprecated in 3.9astterm

ast.AugLoad

variables

A deprecated ctx context class left over from Python 2: the Python 3 parser never creates it and the compiler does not accept it. Deprecated since 3.9.

Syntax

ast.AugLoad()  # устарел, не используется

The class still imports, and touching it emits no warning, so old code testing isinstance(ctx, ast.AugLoad) silently never matches. In x += 1 the target gets a plain Store, and reading the old value is not represented by a separate node — compare the context against ast.Load and ast.Store. The class is deprecated and will be removed in some future version.

Examples

import ast
node = ast.parse('x += 1').body[0]
print(type(node.target.ctx).__name__)  # → Store
print(issubclass(ast.AugLoad, ast.expr_context))  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy