pyebnf/operator.py
def pprint(root, depth=0, space_unit="    "):
  """Pretty print an optree, starting at root."""
  spacing = space_unit * depth

  if isinstance(root, OptreeNode):
    print("{0}Operator ({1})".format(spacing, root.opnode.operator.symbol if root.opnode else "None -> IDENTITY"))
    for operand in root.operands:
      pprint(operand, depth + 1)
  else:
    print("{0}• {1}".format(spacing, root))
def pprint(root, depth=0, space_unit="    "):
  """Pretty print an optree, starting at root."""
  spacing = space_unit * depth

  if isinstance(root, OptreeNode):
    print("{0}Operator ({1})".format(spacing, root.opnode.operator.symbol if root.opnode else "None -> IDENTITY"))
    for operand in root.operands:
      pprint(operand, depth + 1)
  else:
    print("{0}• {1}".format(spacing, root))
Pretty print an optree, starting at root.