Python dataclass serializer/deserializer
Project description
Mew: python dataclass serializer/deserializer
from dataclasses import dataclass
from enum import Enum
from typing import List
import mew
class Type(Enum):
normal = 'normal'
electric = 'electric'
fire = 'fire'
fighting = 'fighting'
water = 'water'
psychic = 'psychic'
@mew.serializable
@dataclass
class Pokemon:
name: str
pokedex: int
type: Type
abilities: List[str]
>>> pikachu = Pokemon('Pikachu', 25, Type.electric, ['static', 'lightning rod'])
>>> pikachu
Pokemon(name='Pikachu', pokedex=25, type=<Type.electric: 'electric'>, abilities=['static', 'lightning rod'])
>>> pikachu.dumps()
'{"name": "Pikachu", "pokedex": 25, "type": "electric", "abilities": ["static", "lightning rod"]}'
>>> assert pikachu == Pokemon.loads(pikachu.dumps())
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
mew-0.1.4.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file mew-0.1.4.tar.gz
.
File metadata
- Download URL: mew-0.1.4.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d38595e049aed4f580dea9b0537a94be275adc3c1e67bfa51689a9465a04de0 |
|
MD5 | 8ed2e5c2a1dbe661f48342f7c29e3781 |
|
BLAKE2b-256 | ab65ba5ccbcc6079982eee4bd353c840e961dddc5d57bde902a674f561c39edb |
File details
Details for the file mew-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: mew-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4a7d2652bcb4eec10a105930200574c201733ec25c88cb0fb8e8c03eec61e97 |
|
MD5 | d84fc3b6571887db9dc73cd95ae9817f |
|
BLAKE2b-256 | 1254217c0df8bce456f93b019d7dac9310b498615f68de804205e8dbcd9f02f8 |