Python package to deflate and re-inflate dictionaries.
How do I install this package?
As usual, just download it using pip:
pip install deflate_dict
Tests Coverage
Since some software handling coverages sometime get slightly different results, here’s three of them:
Deflating a dictionary
A dictionary will be deflated down to its smallest non-further iterable elements, defined as those not containing lists or dictionaries.
from deflate_dict import deflate
D = {
"a":[
{
"b":(0,1,2)
},
{
"c": [1,2,3]
}
]
}
result = deflate(D, sep="_")
# {'a_0_b': (0, 1, 2), 'a_1_c': [1, 2, 3], 'd': 4}
Inflate a dictionary
To reinflate a dictionary to its forgotten glory, just go with:
from deflate_dict import inflate
D = {"a_0_b": (0, 1, 2), "a_1_c": [1, 2, 3], "d": 4}
result = inflate(D, sep="_")
# {'a': [{'b': (0, 1, 2)}, {'c': [1, 2, 3]}], 'd': 4}
Limitations
The library, as of version 1.0.2, is unable to distinguish between reinflated numerical strings and actual numbers, since to deflate the strings the library has to convert the numbers to strings.
Release files for deflate-dict 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deflate_dict-1.0.3.tar.gz | 4.4 kB | Details |
Release files / deflate_dict-1.0.3.tar.gz
| Download URL | deflate_dict-1.0.3.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88b0ed4fe58a3378e7541e22654ce04828f48c1c8305da3f56d51ec416a06c3f
|
|
BLAKE2b-256 checksum How to use checksums |
50e6529f51601a4e6b0965a4ca8d571e568c071b1b604a424aa04fa12d9cffc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|