Sets of integers like 1,3-7,33
Project description
intspan is a set subclass that conveniently represents sets of integers. Sets can be created from, and displayed as, integer spans such as 1-3,14,29,92-97 rather than exhaustive member listings. Compare:
intspan('1-3,14,29,92-97') [1, 2, 3, 14, 29, 92, 93, 94, 95, 96, 97]
Or worse, the unsorted, non-intuitive listings that crop up with Python’s native unordered sets, such as:
set([96, 1, 2, 3, 97, 14, 93, 92, 29, 94, 95])
While they all indicate the same values, intspan output is much more compact and comprehensible. It better divulges the contiguous nature of segments of the collection, making it easier for humans to quickly determine the “shape” of the data and ascertain “what’s missing?”
When iterating, pop()-ing an item, or converting to a list, intspan behaves as if it were an ordered–in fact, sorted–collection. A key implication is that, regardless of the order in which items are added, an intspan will always be rendered in the most compact, organized form possible.
The main draw is having a convenient way to specify, manage, and see output in terms of ranges–for example, rows to process in a spreadsheet. It can also help you quickly identify or report which items were not successfully processed in a large dataset.
There is also an ordered intspanlist type that helps specify the ordering of a set of elements.
See the full details on Read the Docs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file intspan-1.6.1.tar.gz
.
File metadata
- Download URL: intspan-1.6.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ebefbfeeea9fd07e50e3969671712ed3ade730355d3224a41829fc31f7fc0b2 |
|
MD5 | 0e11e93b64cac63e5e906b39b9462e88 |
|
BLAKE2b-256 | 16494b1bcbd6b257422fe1c9f2fef3e0215b80465a5a1f80434dc8b95e096c87 |
File details
Details for the file intspan-1.6.1-py3-none-any.whl
.
File metadata
- Download URL: intspan-1.6.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78ea01107adb4c9b833b707ac3d8aec0ae69ce1cee9362fed6d2a3fb4fef24c7 |
|
MD5 | 4fe07f25824bc1f31eab22d092afeffd |
|
BLAKE2b-256 | cbe5f282d2d3a11d6174d9bba02904c67c49e673007d5593ba82d75d8fff5268 |