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.6.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for NestyDict-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91404371d827d761bc76929fdcc6b151144b90be363f958460b882e23f72b2bf |
|
MD5 | bb39b8a0662d4b6c7a772006c74ed98a |
|
BLAKE2b-256 | 721c5417e1d79dcd6f1c0dc84fc6298bfe1a3e2bc946376e3cdf759b2c2d5058 |