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.0.tar.gz
(3.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dotdict_plus-1.0.0.tar.gz.
File metadata
- Download URL: dotdict_plus-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36c4773735fbe7d6cfee6a3206ad0b173a27b31b512a0f0904d1bb829fdc2e89
|
|
| MD5 |
2049b52fcdee5edcf657714ff18f65e1
|
|
| BLAKE2b-256 |
083c7afa8945c7270ea3a9c7693c45853f75206d43e2d451fe228e83fe7a09c4
|
File details
Details for the file dotdict_plus-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dotdict_plus-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48d985e8149452807fc78eb49e228d8e2a694312b6093648561f379bdfb8a58a
|
|
| MD5 |
17fe4822229e64f742616ff6692e255c
|
|
| BLAKE2b-256 |
b663efadd2e8b02b56f481ad9b8327d04f5a78ecd7797f93c3f21dcc8888c37f
|