Package TestON :: Package core :: Module ast :: Class NodeVisitor
[hide private]
[frames] | no frames]

Class NodeVisitor

source code

object --+
         |
        NodeVisitor

A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the `visit` method.

This class is meant to be subclassed, with the subclass adding visitor methods.

Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `visit` method. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead.

Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications.

Instance Methods [hide private]
 
visit(self, node)
Visit a node.
source code
 
generic_visit(self, node)
Called if no explicit visitor function exists for a node.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__