Commits

Łukasz Langa committed cc7b13a

some cleanups before publishing the WIP

  • Participants
  • Parent commits 60b9a04

Comments (0)

Files changed (2)

+"""A future pprint replacement for py3k."""
+# FIXME: Introduce an overview here.
+
 from collections import Callable
 import io
 import re
 
 
 class TupleFormatter(Formatter):
+    """Formatter for sequences, applicable for tuples and lists (after
+    customization)."""
+
     # Whether multiple values should be printed on one line
     MULTIPLE_VALUES = True
     # Whether to write the comma after last value
 def pprint(object, stream=sys.stdout, indent=None, width=80, depth=None):
     """Utility function for printing out any object in a natty way. API mimics
     pprint.pprint."""
+
     if indent is not None:
         raise NotImplementedError("Not implemented: changing indentation.")
     if depth is not None:
     if omit_first_line:
         result = result[indent:]
     return result
-
-if __name__ == '__main__':
-    WIDTH = 30
-    _width = WIDTH if WIDTH else 80
-    import random
-    import pprint as old
-    def both(object, only_natty=False):
-        pprint(object, width=WIDTH)
-        if not only_natty:
-            print("""
-  vs.
-""")
-            old.pprint(object)
-        print("*" * _width)
-
-    print("*" * _width)
-    a = lambda: ["#" * random.randrange(1, 10) for i in range(random.randrange(10, 20))]
-    b = lambda: [a() for i in range(10)]
-    funkylist = [b() for i in range(5)]
-    both(funkylist, only_natty=True)

test_nattyprint.py

 #!/usr/bin/env python3
+
 import collections
 import functools
 import nattyprint