python2.7-compiler-package

Changeset

13:5d56279993e4
2012-07-06 Paul Boddie raw files shortlog changelog graph Added string "display" representations for Python 2.7 nodes.
compiler/ast.py (file)
     1.1 --- a/compiler/ast.py	Thu Jul 05 23:58:28 2012 +0200
     1.2 +++ b/compiler/ast.py	Fri Jul 06 00:10:51 2012 +0200
     1.3 @@ -1246,6 +1246,9 @@
     1.4      def __repr__(self):
     1.5          return "SetComp(%r, %r)" % (self.expr, self.quals)
     1.6  
     1.7 +    def __str__(self):
     1.8 +        return "{%s %s}" % (self.expr, " ".join(map(str, self.quals)))
     1.9 +
    1.10      def visit(self, visitor, *args):
    1.11          return visitor.visitSetComp(self, *args)
    1.12  
    1.13 @@ -1273,6 +1276,9 @@
    1.14      def __repr__(self):
    1.15          return "DictComp(%r, %r, %r)" % (self.key, self.value, self.quals)
    1.16  
    1.17 +    def __str__(self):
    1.18 +        return "{%s : %s %s}" % (self.key, self.value, " ".join(map(str, self.quals)))
    1.19 +
    1.20      def visit(self, visitor, *args):
    1.21          return visitor.visitDictComp(self, *args)
    1.22  
    1.23 @@ -1592,6 +1598,9 @@
    1.24      def __repr__(self):
    1.25          return "Set(%r)" % (self.nodes,)
    1.26  
    1.27 +    def __str__(self):
    1.28 +        return "{%s}" % ", ".join(map(str, self.nodes))
    1.29 +
    1.30      def visit(self, visitor, *args):
    1.31          return visitor.visitSet(self, *args)
    1.32