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)
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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bb23c333042e71b9716969c3d78b979e55e62a458cbf2ebd1c0e284dcdf5cda
|
|
| MD5 |
e831f8b84712dc1a4b54421e6a0e1027
|
|
| BLAKE2b-256 |
612867f16cbfa31a94fbbb6561a2d151d0a759241bf811c70aa5da7b553b510a
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0abc906a3c8958b81fac825116e675e20c138585c02b304a6e8159fd5325d42
|
|
| MD5 |
d9c9a2089c92bf33f483612a991645f2
|
|
| BLAKE2b-256 |
48b06fe397a0062cff2633c5e9cfb06cebd7fbc7211ca5bc30c5c06986c377e8
|