Overview
Immutable data structures based on estruttura.
Examples
>>> from datta import Data, attribute
>>> class Point(Data):
... x = attribute(types=int)
... y = attribute(types=int)
...
>>> point_a = Point(3, 4)
>>> point_a
Point(3, 4)
>>> point_b = point_a.update(x=30, y=40)
>>> point_b
Point(30, 40)
>>> from datta import Data, attribute, list_attribute
>>> from tippo import Literal
>>> class Vehicle(Data):
... kind = attribute(types=str)
...
>>> class Garage(Data):
... vehicles = list_attribute(types=Vehicle)
... gate = attribute(default="automatic", types=str) # type: Literal["automatic", "manual"]
...
>>> garage = Garage([Vehicle("bicycle"), Vehicle("car")], gate="manual")
>>> garage
Garage([Vehicle('bicycle'), Vehicle('car')], gate='manual')
>>> garage.serialize() == {"vehicles": [{"kind": "bicycle"}, {"kind": "car"}], "gate": "manual"}
True
>>> Garage.deserialize({"vehicles": [{"kind": "bicycle"}, {"kind": "car"}], "gate": "manual"}) == garage
True
>>> from datta import list_cls
>>> MyStrList = list_cls(converter=str, qualified_name="MyStrList")
>>> my_str_list = MyStrList([1, 2.2, None, True])
>>> my_str_list
MyStrList(['1', '2.2', 'None', 'True'])
Release files for datta 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| datta-1.0.1.tar.gz | 12.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datta-1.0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 27.1 kB
Release files / datta-1.0.1.tar.gz
| Download URL | datta-1.0.1.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c687727cda3545857a4fc0c010c43457d9bcbf4328fe5b0988a33f9186a5917a
|
|
BLAKE2b-256 checksum How to use checksums |
964951de4f967a9e6fa98790b8234ff4fe59322efd1179524a72d32ddecad701
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / datta-1.0.1-py2.py3-none-any.whl
| Download URL | datta-1.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9c10a35a3ad380ad19ce973de94bde2720bfc0abfc8a204fa7fa60a2ab256abc
|
|
BLAKE2b-256 checksum How to use checksums |
d44ab3f69bbb3e76d980350ccc7d05781cf8f07f5dd8291f760b43f5b511d6c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|