ace91d
diff --git a/q.py b/q.py
ace91d
index 1bf76d0..5a05ecb 100644
ace91d
--- a/q.py
ace91d
+++ b/q.py
ace91d
@@ -66,7 +66,7 @@
ace91d
 class Q(object):
ace91d
     __doc__ = __doc__  # from the module's __doc__ above
ace91d
 
ace91d
-    import ast, code, inspect, os, pydoc, sys, random, re, time
ace91d
+    import ast, code, inspect, os, pydoc, sys, random, re, time, pprint
ace91d
 
ace91d
     # The debugging log will go to this file; temporary files will also have
ace91d
     # this path as a prefix, followed by a random number.
ace91d
@@ -177,6 +177,13 @@ def unindent(self, lines):
ace91d
         indent = min(len(self.re.match(r'^ *', line).group()) for line in lines)
ace91d
         return [line[indent:].rstrip() for line in lines]
ace91d
 
ace91d
+    def save_large_value(self, value):
ace91d
+        if isinstance(value,  self.TEXT_TYPES):
ace91d
+            value = value.encode('utf-8')
ace91d
+        path = self.OUTPUT_PATH + '%08d.txt' % self.random.randrange(1e8)
ace91d
+        self.FileWriter(path).write('w', value)
ace91d
+        return path
ace91d
+
ace91d
     def safe_repr(self, value):
ace91d
         # TODO: Use colour to distinguish '...' elision from actual '...' chars.
ace91d
         # TODO: Show a nicer repr for SRE.Match objects.
ace91d
@@ -184,11 +191,17 @@ def safe_repr(self, value):
ace91d
         result = self.TEXT_REPR.repr(value)
ace91d
         if isinstance(value, self.BASESTRING_TYPES) and len(value) > 80:
ace91d
             # If the string is big, save it to a file for later examination.
ace91d
-            if isinstance(value,  self.TEXT_TYPES):
ace91d
-                value = value.encode('utf-8')
ace91d
-            path = self.OUTPUT_PATH + '%08d.txt' % self.random.randrange(1e8)
ace91d
-            self.FileWriter(path).write('w', value)
ace91d
+            path = self.save_large_value(value)
ace91d
             result += ' (file://' + path + ')'
ace91d
+        else:
ace91d
+            # Use pretty print if no specific choices were found
ace91d
+            pp = self.pprint.PrettyPrinter(indent=1)
ace91d
+            formatted = pp.pformat(value)
ace91d
+            if len(formatted) > 80:
ace91d
+                path = self.save_large_value(formatted)
ace91d
+                result += ' (file://' + path + ')'
ace91d
+            else:
ace91d
+                result = formatted
ace91d
         return result
ace91d
 
ace91d
     def get_call_exprs(self, line):