Python package to deflate and re-inflate dictionaries.
Project description
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}
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
deflate_dict-1.0.1.tar.gz
(4.1 kB
view hashes)