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 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page