Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

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.

Files for objectmapper, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size objectmapper-0.0.7-py3-none-any.whl (6.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size objectmapper-0.0.7.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page