Skip to main content

Python type converter

Project description

TypePigeon

tests codecov build version license style

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]) with guard_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


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 details)

Uploaded Source

Built Distribution

typepigeon-1.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file typepigeon-1.0.1.tar.gz.

File metadata

  • Download URL: typepigeon-1.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for typepigeon-1.0.1.tar.gz
Algorithm Hash digest
SHA256 af8524d4dd6a2338dc3a4ce4c7f44f13577abefb584fb9250e3b70b646520306
MD5 9957e55e354d41b13f2f1c811f756418
BLAKE2b-256 d1c74cf07faf4af501188c3191b1c8520bbea7a72fb3875b44da76cca24cd0fe

See more details on using hashes here.

File details

Details for the file typepigeon-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: typepigeon-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for typepigeon-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a38cfcdf88ce4f48ad76718094919d641b3bcd9bfc2b22715069658e6747b3b4
MD5 2d9965c66053e2897ecaf218c734efb2
BLAKE2b-256 1095aab671082b5a6117d6799d0430c5bab687e48904cdacac162e9f3b6d799a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page