Skip to main content

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)

Uploaded source

Built Distribution

NestyDict-0.0.6-py3-none-any.whl (3.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page