Basic type casting.
Project description
castfit
Basic type casting.
Changelog - Issues - Documentation
Why?
I'm writing more and more type-checked code, but I often get a bunch of strings I need to convert (e.g., from docopt
).
pydantic
feels heavy.type-docopt
uses a new syntax.bottle
seems like good inspiration for small, useful libraries.
Install
python -m pip install castfit
Example
from pathlib import Path
from castfit import castfit
class Cat:
name: str
age: int
weight: float
logo: Path
bob = castfit(Cat, dict(name="Bob", age="4", weight="3.2", logo="./bob.png"))
assert bob.name == "Bob"
assert bob.age == 4
assert bob.weight == 3.2
assert bob.logo == Path("./bob.png")
License
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
castfit-0.1.0.tar.gz
(8.4 kB
view hashes)