Utility functions to convert strings to Python types
Project description
# conversion
Utility functions to convert strings to Python types.
## convert_bool
Converts truthy strings to True and falsey strings to False:
` >>> from conversion import convert_bool >>> convert_bool('yes') True >>> convert_bool('no') False `
When the function does not find the string can be converted, ValueError is raised:
` >>> convert_bool('yup') ValueError: invalid truth value 'yup' `
## convert_delta
Converts time with unit suffixes into datetime.timedelta objects:
` >>> from conversion import convert_delta >>> convert_delta('1h') datetime.timedelta(0, 3600) `
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
File details
Details for the file conversion-0.0.4rc2.tar.gz.
File metadata
- Download URL: conversion-0.0.4rc2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f490fa2fa5b88ad86ad93c70408986ee97b35522ba887ca47e6b4d46b0091ac5
|
|
| MD5 |
c2ed06b2a2c8e4d13c681c6384f10a2d
|
|
| BLAKE2b-256 |
b05debe7a5bc36f1557442bc2fe9e43cc98bf459c0da47f13a8791c5df89a75d
|