2013-07-01 | Paul Boddie | raw annotate files changeset graph | Introduced numbered functions where rebinding occurs in namespaces. Added an original name attribute to classes and functions, revised the check for usage of functions when generating code or reports, and added rebinding statements to module "main program" syspython output. Fixed the attribute operation generated by syspython when acquiring module attributes for a "from" statement. | 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