class documentation

class op_util: (source)

View In Hierarchy

This class provides data and functions for mapping AST nodes to symbols and precedences.

Class Precedence Undocumented
Class Method get_op_precedence Given an AST node object, returns the precedence.
Class Method get_op_symbol Given an AST node object, returns a string containing the symbol.
@classmethod
def get_op_precedence(cls, obj: ast.AST, precedence_data: dict[type[ast.AST] | None, int] = _precedence_data, type: Callable[[object], type[Any]] = type) -> int: (source)

Given an AST node object, returns the precedence.

Raises
KeyErrorIf the node is not explicitely supported by this function. This is a very legacy piece of code, all calls to get_op_precedence should be guarded in a try:... except KeyError:... statement.
@classmethod
def get_op_symbol(cls, obj: ast.operator | ast.boolop | ast.cmpop | ast.unaryop, fmt: str = '%s', symbol_data: dict[type[ast.AST] | None, str] = _symbol_data, type: Callable[[object], type[Any]] = type) -> str: (source)

Given an AST node object, returns a string containing the symbol.