On this page
  1. ast.Attribute
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from ast import Attribute
help(Attribute)

Linked from

Related notes