A small module for mapping between object types.
Project description
A small module for mapping between object types.
Installation
objectmapper requires Python >= 3.6 because it relies on modern type annotations.
pip install objectmapper
Example
>>> import objectmapper >>> mapper = objectmapper.ObjectMapper() >>> # One-to-one mappings >>> def int_to_str(i: int) -> str: ... return str(i) >>> mapper.create_map(int, str, int_to_str) >>> mapper.map(42, str) '42' >>> # Many-to-one mappings >>> def int_float_to_str(i: int, f: float) -> str: ... return str(i + f) >>> mapper.create_map((int, float), str, int_float_to_str) >>> mapper.map((42, 42.5), str) '84.5'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
objectmapper-0.0.7.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for objectmapper-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e47cd9168206295e0a93c703bcd9801d98c19aea9af93eb8547170be64f751a |
|
MD5 | 8dbbbf52db9aaffb63cb8bd067b80345 |
|
BLAKE2b-256 | f7d429d9543996cb487e60f58410e1e45d3fd0bb29727194ddb7a997059db11b |