MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / visit

Method visit

src/8/implementing_the_visitor_pattern/example.py:38–43  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

36
37class NodeVisitor:
38 def visit(self, node):
39 methname = 'visit_' + type(node).__name__
40 meth = getattr(self, methname, None)
41 if meth is None:
42 meth = self.generic_visit
43 return meth(node)
44
45 def generic_visit(self, node):
46 raise RuntimeError('No {} method'.format('visit_' + type(node).__name__))

Callers 10

visit_AddMethod · 0.45
visit_SubMethod · 0.45
visit_MulMethod · 0.45
visit_DivMethod · 0.45
generate_codeMethod · 0.45
binopMethod · 0.45
unaryopMethod · 0.45
example.pyFile · 0.45
example1.pyFile · 0.45
lowerFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected