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.2.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.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dotdict_plus-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e7bf121e40df1182e6ddcbb8bb7845132e074ed2028f7a446fd14fd7c85ab34d
MD5 c1699dd9a131f0d45f466f9f10257623
BLAKE2b-256 4a97af10c54c35ba6dfc02e58dce597c537119bdf03daba53c0965f020ff7002

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dotdict_plus-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dfc58836c4844f9f94620f28bf0a4d068358d6a2573831f63e8b04f7ff3e90a4
MD5 f28cf072bcb4dd414cb830781a738679
BLAKE2b-256 c13492d407c44a2d05d31fe31dba69d239849f5689e25d281158cbbe0c1f960e

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