Skip to main content

A fork of the cpython's pprint which gives standard indentation.

Project description

Python’s standard library contains a pretty print module (pprint), but it’s output is in a very odd style. This project is a fairly straightforward fork which aim to create output suitable for use in python code with standard formatting.

I copied both pprint.py and test_pprint.py from the cpython (2.6) code base, and made the minimal changes to make things work, and all the tests pass. The result should be equally reliable as the stdlib pprint library.

>>> example_obj = {1:2, 3:4, 'range':range(3)}
>>> example_obj['range'].append(range(5))
>>> example_obj['range'].append(range(20))
>>> import buck.pprint
>>> buck.pprint.pprint(example_obj)
{
    1: 2,
    3: 4,
    'range': [
        0,
        1,
        2,
        [0, 1, 2, 3, 4],
        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
    ],
}

This is how I’d format this object in my own code. Below is the formatting that the standard pprint gives. I believe you’ll agree that it’s not a style you’ve ever seen in real python code.

>>> import pprint
>>> pprint.pprint(example_obj)
{1: 2,
 3: 4,
 'range': [0,
           1,
           2,
           [0, 1, 2, 3, 4],
           [0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19]]}

History

0.0

2013-03-28 – Initial release.

Project details


Release history Release notifications | RSS feed

This version

0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buck.pprint-0.0.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file buck.pprint-0.0.tar.gz.

File metadata

  • Download URL: buck.pprint-0.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for buck.pprint-0.0.tar.gz
Algorithm Hash digest
SHA256 f4f110d370262bf971269020d47dec5f795de334b6365fcf8fd610f9df1a2ec8
MD5 0380a98b0348510c2fde4db696f27c2d
BLAKE2b-256 d77af59450dbe6fd7fdab3bd40195358cd08ccb316da2fa47bfeb5b734896269

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page