Flatten and inflate a dictionary
Project description
#PyDX
Tool to flatten a nested dictionary.
##Installation PyDX is available on pypi:
pip install PyDX-DevWorks8
##Example
from PyDX import pydx
nested = {"Settings":
{"General":
{"Font":
{"Name": "Helvica",
"Size": "1"
}
},
"Network":
{"Frontend":
{"ip": "127.0.0.1",
"port": "6000"},
"Backend":
{"ip": "127.0.0.1",
"port": "6001"
}
}
}
}
expected_results = {'Settings_General_Font_Name': 'Helvica',
'Settings_General_Font_Size': '1',
'Settings_Network_Frontend_ip': '127.0.0.1',
'Settings_Network_Frontend_port': '6000',
'Settings_Network_Backend_ip': '127.0.0.1',
'Settings_Network_Backend_port': '6001'}
flat = pydx.flatten(nested)
assert expected_results == flat
expand = pydx.inflate(flat)
assert nested == expand
##Results
flat = pydx.flatten(nested)
print(flat)
{'Settings_General_Font_Name': 'Helvica', 'Settings_General_Font_Size': '1', 'Settings_Network_Frontend_ip': '127.0.0.1', 'Settings_Network_Frontend_port': '6000', 'Settings_Network_Backend_ip': '127.0.0.1', 'Settings_Network_Backend_port': '6001'}
expand = pydx.inflate(flat)
print(expand)
{'Settings': {'General': {'Font': {'Name': 'Helvica', 'Size': '1'}}, 'Network': {'Frontend': {'ip': '127.0.0.1', 'port': '6000'}, 'Backend': {'ip': '127.0.0.1', 'port': '6001'}}}}
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
PyDX-DevWorks8-1.0.0.tar.gz
(2.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PyDX-DevWorks8-1.0.0.tar.gz.
File metadata
- Download URL: PyDX-DevWorks8-1.0.0.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d812b00b1e042811af870bac9737a192a77efce2fc60d59a0998957e070e1f
|
|
| MD5 |
83d9e93793d67f486655f734b33de94d
|
|
| BLAKE2b-256 |
68fd2ce1a8c727ba11a46343528617d7ac2677d207ba11cd25a61d2dad3d8a7c
|
File details
Details for the file PyDX_DevWorks8-1.0.0-py3-none-any.whl.
File metadata
- Download URL: PyDX_DevWorks8-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dd7e7a2f0658eeee5edd4fa538b077c33702bfdfd28c47878bb01df2463dbdc
|
|
| MD5 |
95785e7a334c2ce3d37e054ef89454a9
|
|
| BLAKE2b-256 |
f1d239b4f7c3e49349f4ccecef2e05d083ceb0f92feb659545c809cfeb50ebfe
|