Skip to main content

A Python library for dot notation access to nested dictionaries

Project description

dot-dict

A Python library for dot notation access to nested dictionaries.

Features

  • Access nested dictionary values using dot notation
  • Automatic creation of nested structures
  • Compatible with standard dictionary operations
  • JSON serialization support
  • Lightweight and efficient

Installation

pip install dotdict-plus

Usage

from dotdict import DotDict

# Create a Dot object from a dictionary
data = {
    "user": {
        "name": "John",
        "age": 30,
        "address": {
            "city": "New York",
            "country": "USA"
        }
    }
}

dot_data = DotDict(data)

# Access values using dot notation
print(dot_data.user.name)  # Output: John
print(dot_data.user.address.city)  # Output: New York

# Set values using dot notation
dot_data.user.age = 31
dot_data.user.email = "john@example.com"

# Automatic creation of nested structures
dot_data.settings.theme = "dark"
dot_data.settings.language = "en"

# Convert back to dictionary
dict_data = dot_data.to_dict()

# JSON serialization
print(str(dot_data))

Development

pytest

pytest

Setup

# Clone the repository
git clone https://git.xmov.ai/jiangbin/dot-dict.git
cd dot-dict

# Install development dependencies
pip install -e ".[dev]"

Upload

make upload-test

License

MIT License

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

dotdict_plus-1.0.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotdict_plus-1.0.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file dotdict_plus-1.0.3.tar.gz.

File metadata

  • Download URL: dotdict_plus-1.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for dotdict_plus-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9bb23c333042e71b9716969c3d78b979e55e62a458cbf2ebd1c0e284dcdf5cda
MD5 e831f8b84712dc1a4b54421e6a0e1027
BLAKE2b-256 612867f16cbfa31a94fbbb6561a2d151d0a759241bf811c70aa5da7b553b510a

See more details on using hashes here.

File details

Details for the file dotdict_plus-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: dotdict_plus-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for dotdict_plus-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f0abc906a3c8958b81fac825116e675e20c138585c02b304a6e8159fd5325d42
MD5 d9c9a2089c92bf33f483612a991645f2
BLAKE2b-256 48b06fe397a0062cff2633c5e9cfb06cebd7fbc7211ca5bc30c5c06986c377e8

See more details on using hashes here.

Supported by

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