Skip to main content

The standard library pprint module, but sets are always ordered.

Project description

PPrint Ordered Sets

The standard library pprint module, but with the feature that all sets are ordered.

Why does this package exist?

This package is a backport for the bug-fix bpo-27495. This package ensures that set and frozenset objects are always ordered, which is not true of the pprint module.

As of writing this, the pull request that fixes this bug has not been merged.

Example

>>> import pprint_ordered_sets as pprint
>>> obj = set("abcdefg")
>>> print(obj)  # Will be different on different systems.
{'d', 'f', 'b', 'g', 'e', 'a', 'c'}
>>> pprint.pp(obj)  # Will be same on all systems.
{'a', 'b', 'c', 'd', 'e', 'f', 'g'}

License

This code is licensed under the Python Software Foundation license, as this is a derivative work. My changes are adding the default ordering of set and frozenset objects, writing additional tests to cover these features, and renaming of this module to pprint_ordered_sets.

Testing

This package requires no dependencies to test, simply run:

python -m unittest test_pprint_ordered_sets.py

Project details


Download files

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

Source Distribution

pprint_ordered_sets-1.0.0.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distribution

pprint_ordered_sets-1.0.0-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

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