2013-02-18 | Paul Boddie | raw annotate files changeset graph | Added headings. | syspython-as-target |
1 #!/usr/bin/env python 2 3 class C: 4 def __init__(self): 5 self.visitor = self 6 7 def default(self, node): 8 return 123 9 10 def dispatch(self, node): 11 try: 12 return node.visit(self.visitor) 13 except AttributeError: 14 return self.visitor.default(node) 15 16 class N: 17 def visit(self, visitor): 18 return 456 19 20 c = C() 21 n = N() 22 result_456 = c.dispatch(n) 23 24 # vim: tabstop=4 expandtab shiftwidth=4