provides DTO object for object-like experience with dicts
Project description
python-simple-dto
Dict, that behaves like an object.
To achieve this BasicDTO and DTO were introduced. They brings object-like attribute access appearance to dicts. BasicDTO more suits for “flat” dict and DTO - for more complex.
This Package doesn’t provides validation(there are more suitable tools today) and “fromstring” functionality (single responsibility, you should load data by your own)
Example of usage
DTO
>>> from src.python_simple_dto.dto import DTO
>>> test_dict = {
... "users": [{"name": "Alex", "age": 29}, {"name": "Russel", "age": 19}]
... }
>>> test_dto
{'users': [{'name': 'Alex', 'age': 29}, {'name': 'Russel', 'age': 19}]}
>>> test_dto.users
[{'name': 'Alex', 'age': 29}, {'name': 'Russel', 'age': 19}]
>>>test_dto.roles = ["guest", "user", "moderator"]
>>>test_dto
{'users': [{'name': 'Alex', 'age': 29}, {'name': 'Russel', 'age': 19}], 'roles': ['guest', 'user', 'moderator']}
>>>test_dto.roles
['guest', 'user', 'moderator']
>>>test_dto["roles"]
['guest', 'user', 'moderator']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-simple-dto-0.0.2.tar.gz
.
File metadata
- Download URL: python-simple-dto-0.0.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53925d56d7897cd1370553d4e1d4b0174e344cc7ca356e83bb9a9454591248d3 |
|
MD5 | 3e27f518645de9f920306c8b5d6372b0 |
|
BLAKE2b-256 | 3c5be7646f216b9e8445b745fedfb9ad2c73e492f91411618b027f07dfcb9d35 |
File details
Details for the file python_simple_dto-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: python_simple_dto-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15f999c95ace320bed13e649f4090014e785e9b6c0fa21b62b0a764ed87510ae |
|
MD5 | 9ef986fc81041e76cd9e2e34d503d5bc |
|
BLAKE2b-256 | be50e0b5942f75ac5ef38a0cef7411fa13f9cf2d78898eaa231e7c06cc3185fa |