A package to enable setting and getting of nested dictionaries using paths.
Project description
DottedDict
Examples
from nestydict import Nesty
normal_dict = {
"metrics.cost.name": "cost_micros",
"metrics.cost.value": 123123,
"metrics.campaign": {"name": "Extra Clicks", "metrics.cost_micros": 100},
}
dotted = Nesty.from_dict(normal_dict)
dotted
# {
# "metrics": {
# "cost": {
# "name": "cost_micros",
# "value": 123123
# },
# "campaign": {
# "name": "Extra Clicks",
# "metrics": {
# "cost_micros": 100
# }
# }
# }
# }
from nestydict import Nesty
dotted = Nesty()
dotted["metrics.cost.name"] = "cost_micros"
dotted["metrics.cost.id"] = 123123
dotted["metrics.cost.type"] = "money"
dotted["metrics.campaign"] = [{"A": 1}]
dotted
# {
# "metrics": {
# "cost": {
# "name": "cost_micros",
# "id": 123123,
# "type": "money"
# },
# "campaign": [{"A": 1}],
# }
# }
dotted["metrics.cost"]
# {
# "name": "cost_micros",
# "id": 123123,
# "type": "money"
# }
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
NestyDict-0.0.4.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for NestyDict-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a097ad75f4d82ef3e5091259a2fe7680e22fb3b729cf17502ebb7d3b85e5e11b |
|
MD5 | 48cda684001a9e6efde4413347b31740 |
|
BLAKE2b-256 | b667d0a0a422f308ebf265093bd62f288c1cb4efc4982b0b2c4547c68f270576 |