Python type converter
Project description
TypePigeon
TypePigeon is a Python type converter focused on converting values between various Python data types.
pip install typepigeon
Features
- convert values directly from one Python type to another with
convert_value()
- convert values to JSON format with
convert_to_json()
- convert generic aliases (
List[str]
) to simple collection types ([str]
) withguard_generic_alias()
Usage
With TypePigeon, you can convert simple values from one type to another:
import typepigeon
typepigeon.convert_value(0.55, str)
# '0.55'
typepigeon.convert_value(1, float)
# 1.0
typepigeon.convert_value([1], str)
# '[1]'
Additionally, you can also cast values into a collection:
import typepigeon
typepigeon.convert_value([1, 2.0, '3'], [int])
# [1, 2, 3]
typepigeon.convert_value('[1, 2, 3]', (int, str, float))
# [1, '2', 3.0]
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
typepigeon-1.0.1.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for typepigeon-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a38cfcdf88ce4f48ad76718094919d641b3bcd9bfc2b22715069658e6747b3b4 |
|
MD5 | 2d9965c66053e2897ecaf218c734efb2 |
|
BLAKE2b-256 | 1095aab671082b5a6117d6799d0430c5bab687e48904cdacac162e9f3b6d799a |