On this page
ast.Attribute
Prev: ast.AsyncWith | Up: ast | Next: ast.AugAssign
Rel: ast.Add, ast.alias, ast.And, ast.AnnAssign
Ref: docs.python.org — ast.Attribute
Tags: #public #python3 #stdlib #ast
Import
import ast
from ast import Attribute
Signature & Overview
ast.Attribute(expr value, identifier attr, expr_context ctx)
Attribute(expr value, identifier attr, expr_context ctx)
Usage
import ast
node = ast.parse("obj.attr", mode="eval").body
assert isinstance(node, ast.Attribute) and node.attr == "attr"
Gotchas
.attris a plainstr, while.valueis an expression node (often nestedAttributeorName).
REPL Inspect
from ast import Attribute
help(Attribute)
Linked from
Related notes
- tuts/python3/stdlib_module/ast/AsyncWith Linked here; links to this page; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/AugAssign Linked here; links to this page; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/Add Linked here; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/alias Linked here; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/And Linked here; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/AnnAssign Linked here; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/AST Linked here; shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ast/arg shared tags: #ast, #stdlib
- tuts/python3/stdlib_module/ast/arguments shared tags: #ast, #stdlib