Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:19.3.1 AST NodesUp:19.3 Python Abstract SyntaxNext:19.3.3 Examples

19.3.2 Assignment nodes

There is a collection of nodes used to represent assignments. Eachassignment statement in the source code becomes a singleAssign node in the AST. Thenodes attribute is alist that contains a node for each assignment target. This isnecessary because assignment can be chained, e.g.a = b = 2.EachNode in the list will be one of the following classes:AssAttr,AssList,AssName, orAssTuple.

Each target assignment node will describe the kind of object beingassigned to:AssName for a simple name, e.g.a = 1.AssAttr for an attribute assigned, e.g.a.x = 1.AssList andAssTuple for list and tuple expansionrespectively, e.g.a, b, c = a_tuple.

The target assignment nodes also have aflags attribute thatindicates whether the node is being used for assignment or in a deletestatement. TheAssName is also used to represent a deletestatement, e.g.del x.

When an expression contains several attribute references, anassignment or delete statement will contain only oneAssAttrnode - for the final attribute reference. The other attributereferences will be represented asGetattr nodes in theexpr attribute of theAssAttr instance.


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:19.3.1 AST NodesUp:19.3 Python Abstract SyntaxNext:19.3.3 Examples
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp