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 dot-dict

Usage

from dot_dict import Dot

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

dot_data = Dot(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

Setup

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

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

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.1.tar.gz (3.2 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.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dotdict_plus-1.0.1.tar.gz
Algorithm Hash digest
SHA256 794dcbf0a06ecb48b32be3b09b170880ad1e66aac72f484c1e5052b63d94fba9
MD5 66282fc47fb3d973cf52539a7c40ef72
BLAKE2b-256 2bee8e6e2719e4dd8d5cff47b621738b70a9b284f75a9ac185f5162810b7c9a5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dotdict_plus-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 264b748fb2a1e0365abbdb59f1093a03cb26155ecac280a4470d55304700683b
MD5 cdc0281c9e2181b29c342b2b3f8650af
BLAKE2b-256 d33f7a6d62c4e2fc5536b1447584fec9c7b9a4a436fb089afae1e5555ec45187

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