2017-01-21 | Paul Boddie | raw annotate files changeset graph | Made class and function instance __name__ attributes leafnames, introducing a separate __mname__ attribute on classes and function instances to help support the reproduction of the full path of those objects. Updated the visitor example to use the __name__ attributes of node classes instead of special name attributes. |
1 import operator 2 3 class C: 4 pass 5 6 c = C() 7 print c.__name__ # C 8 print c.__mname__ # __main__ 9 print C.__name__ # C 10 print C.__mname__ # __main__ 11 12 # If it were defined, operator.__name__ would be module. 13 14 print operator.__mname__ # operator 15 16 # If it were defined, operator.add.__name__ would be function. 17 18 print operator.add.__fname__ # add 19 print operator.add.__mname__ # operator.binary