changeset 154:27fae551afef

pprint: Now we have a function for pretty printing directly to strings
author Sigurd Meldgaard <stm@daimi.au.dk>
date Fri, 04 Dec 2009 10:42:39 +0100
parents 79093516662c
children 58ef417d1f76
files pysmcl/pretty_print.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/pretty_print.py	Thu Dec 03 15:13:46 2009 +0100
+++ b/pysmcl/pretty_print.py	Fri Dec 04 10:42:39 2009 +0100
@@ -5,6 +5,7 @@
 program parsed into the ast.
 """
 
+import StringIO
 import pysmcl.ast_wrapper as ast
 import sys
 
@@ -383,3 +384,8 @@
     ***module***
     """
     PrettyPrinter(output).visit(module)
+
+def pprint_string(module):
+    output = StringIO.StringIO()
+    pprint(module, output)
+    return output.getvalue()