PyDocs

Nav

Python Language Services

Assign

ast

class
  • Assign(targets, value, type_comment)
Assign(expr* targets, expr value, string? type_comment)
Members of Assign

t

type_comment
type_comment is an optional string with the type annotation as a comment.
1 Example
>>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment
Module(
    body=[
        Assign(
            targets=[
                Name(id='a', ctx=Store()),
                Name(id='b', ctx=Store())],
            value=Constant(value=1))])

>>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # Unpacking
Module(
    body=[
        Assign(
            targets=[
                Tuple(
                    elts=[
                        Name(id='a', ctx=Store()),
                        Name(id='b', ctx=Store())],
                    ctx=Store())],
            value=Name(id='c'))])
from the Python docs
See Also
No see-alsos for ast/Assign
0 Notes
No notes for Assign