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

ast.BinOp

Prev: ast.Await | Up: ast | Next: ast.BitAnd
Rel: ast.Add, ast.alias, ast.And, ast.AnnAssign
Ref: docs.python.org — ast.BinOp
Tags: #public #python3 #stdlib #ast


Import

import ast
from ast import BinOp

Signature & Overview

ast.BinOp(expr left, operator op, expr right)

BinOp(expr left, operator op, expr right)

Usage

import ast

node = ast.parse("2 + 3", mode="eval").body
assert isinstance(node, ast.BinOp) and node.left.value == 2 and node.right.value == 3

Gotchas

REPL Inspect

from ast import BinOp
help(BinOp)

Linked from

Related notes