deflatable-dict
A dictionary that can be flattened and re-inflated. Particularly useful if you're interacting with yaml, for example.
Installation
with pip:
pip install deflatable-dict
deflatable-dict does not have any dependencies beyond standard python libraries.
Instantiation
from deflatabledict import DeflatableDict
dd = DeflatableDict({
"a": {
"1": True,
"2": False,
},
"b": 20,
})
dd["a.1"] # True
dd["a.2"] # False
dd["b"] # 20
dd["a"] # { "1": True, "2": False }
Deflation
A DeflatableDict can be deflated with .deflate(). This returns a standard dictionary object with flattened keys constructed by concatenating the nested keys with the DeflatableDict's delimiter. A DeflatableDict uses it's deflated form for its string representation.
Delimiter
A DeflatableDict can have it's delimiter specified by passing the desired delimiter as the sep parameter to the DeflatableDict constructor. By default the delimiter if ..
Inflation
A DeflatableDict will automatically inflate any values that are inserted into it. For example:
from deflatabledict import DeflatableDict
dd = DeflatableDict()
dd["a.1"] = True
dd["a.2"] = False
dd["a"] # { "1": True, "2": False }
Development
This project uses .devcontainer to describe the environment to use for development. You may use the environment described in this directory (it integrates automatically with vscode's 'remote containers' extension), or you may create your own environment with the same dependencies.
Dependencies
Install development dependencies with:
pip install .[tests]
Tests
Run tests with:
pytest
Metadata
Release files for deflatable-dict 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deflatable-dict-0.3.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deflatable_dict-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / deflatable-dict-0.3.0.tar.gz
| Download URL | deflatable-dict-0.3.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6536bbf1c6c61f18c96766913a5155043f98a97f300557b5a86e2fc9c80660b
|
|
BLAKE2b-256 checksum How to use checksums |
61b1040fff93ccbcdf396c3d8867f5cbd9a196e7f6ab43a24c66cf99ea9f8cc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15
|
Release files / deflatable_dict-0.3.0-py3-none-any.whl
| Download URL | deflatable_dict-0.3.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67aeb4fe2c62b8669d0429007ce01bc38b7582d9c62a751b42bdde6a8f562591
|
|
BLAKE2b-256 checksum How to use checksums |
301ff7093309c1c5c431abe3b89bd382e6629d095e9b36c96c630444357c598f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.15
|