Convert dictionaries into objects with attribute-style access.
Project description
DictToObject
DictToObject is a Python utility class that converts dictionaries into objects, allowing you to access keys as attributes.
Installation
Install using pip:
pip install dicttoobject
Dependencies
- termcolor: python
Example
- Import the
DictToObjectclass:
from dicttoobject import DictToObject
- Create a dictionary:
data = {
'name': 'John Doe',
'age': 30,
'address': {
'street': '123 Main St',
'city': 'New York'
}
}
- Convert the dictionary into an object:
obj = DictToObject(data)
# Accessing attributes
print(obj.name) # Output: John Doe
print(obj.age) # Output: 30
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
dtob-1.1.2.tar.gz
(1.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
dtob-1.1.2-py3-none-any.whl
(1.8 kB
view details)
File details
Details for the file dtob-1.1.2.tar.gz.
File metadata
- Download URL: dtob-1.1.2.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
108b40f92813a6a5963dfefa03df3221f3c6c363c23e4cd072d2f13df1a796c2
|
|
| MD5 |
9d0e25614ecc89b179e3181c5b8696f4
|
|
| BLAKE2b-256 |
19e8f4015f0de7c3d4a859c4486e3ac1914a9a8180afaa6595bff81ee7c00837
|
File details
Details for the file dtob-1.1.2-py3-none-any.whl.
File metadata
- Download URL: dtob-1.1.2-py3-none-any.whl
- Upload date:
- Size: 1.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52b459507f025da1c8dbbc82374cdee9d9a96ec97ce5f764b361e74cd14d2dc4
|
|
| MD5 |
9805640946754d887402ecb80bad60e4
|
|
| BLAKE2b-256 |
43f7567986f1670a15f88f500d3fe991282929759c393721b4690df345bacb83
|