NodeTransformer Class

Inheritance diagram of NodeTransformer

class NodeTransformer

Walks the abstract syntax tree and allows modifications of nodes.

The NodeTransformer will walk the AST and use the return value of the visitor functions to replace or remove the old node. If the return value of the visitor function is None the node will be removed from the previous location otherwise it’s replaced with the return value. The return value may be the original node in which case no replacement takes place.

Methods

generic_visit(node, *args, **kwargs)
get_visitor(node) Return the visitor function for this node or None if no visitor
visit(node, *args, **kwargs) Visit a node.
visit_list(node, *args, **kwargs) As transformers may return lists in some places this method

Descriptions

class NodeTransformer

Method details

generic_visit(node, *args, **kwargs)
visit_list(node, *args, **kwargs)

As transformers may return lists in some places this method can be used to enforce a list as return value.

Inherited member details

get_visitor(node)

Return the visitor function for this node or None if no visitor exists for this node. In that case the generic visit function is used instead.

visit(node, *args, **kwargs)

Visit a node.

Table Of Contents

Previous topic

NodeVisitor Class

Next topic

NodeVisitor Class