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
Close
Hashes for python_simple_dto-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15f999c95ace320bed13e649f4090014e785e9b6c0fa21b62b0a764ed87510ae |
|
MD5 | 9ef986fc81041e76cd9e2e34d503d5bc |
|
BLAKE2b-256 | be50e0b5942f75ac5ef38a0cef7411fa13f9cf2d78898eaa231e7c06cc3185fa |