Python Glossary Русский

all Python 3deprecated in 3.9astterm

ast.AugStore

variables

A deprecated ctx context class for the write in an augmented assignment, left over from Python 2. The Python 3 parser never creates it; deprecated since 3.9.

Syntax

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

In Python 3 the target of a.b += 1 gets the ordinary Store context, not AugStore, so a filter on this class finds nothing. Accessing ast.AugStore emits no warning — the deprecation is visible only in the documentation and What's New 3.9. Check isinstance(node, ast.AugAssign) and the ast.Store context on the target instead.

Examples

import ast
target = ast.parse('a.b += 1').body[0].target
print(type(target).__name__, type(target.ctx).__name__)  # → Attribute Store
print(type(target.value.ctx).__name__)  # → Load

See also

Open in the full glossarydocs.python.orgReport an inaccuracy