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.5.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file typepigeon-1.0.5.tar.gz
.
File metadata
- Download URL: typepigeon-1.0.5.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80dc513464da390dbc4be6d065d113e89efff2160f82fe28819981e40110991a |
|
MD5 | 692bc90de853437f053632ff0f869f6d |
|
BLAKE2b-256 | b055338fcea206a2a8467c978b0f2c1e73e91420ff26553c6019127a12bb9ef8 |
File details
Details for the file typepigeon-1.0.5-py3-none-any.whl
.
File metadata
- Download URL: typepigeon-1.0.5-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7e3dd21c49cc295c01c44e47e3bbe107c7bd5ff615a59654353d42de6905e78 |
|
MD5 | b7efd2be47214697ad502d831c6cee8a |
|
BLAKE2b-256 | bff0b312528601118dc667b93aa77d2470e44d6155a38b3b06d35e8a2d5caa08 |