Read Strings
Project description
readstr
Provides readstr
, a function that can read a lot of different types from strings:
from readstr import readstr
import typing
import uuid
readstr('1,2,3', typing.Set[int])
readstr('foo=3,bar=10', typing.Dict[str, int])
readstr('vUfDOuQwRVavn3_QjMxp7Q', uuid.UUID)
Useful for reading arguments from command line arg, from environment variables, etc.
Extensible
from dataclasses import dataclass
from typing import List
from readstr import readstr, reads
@dataclass
class Path:
path: str
@reads
def read_path(str_value: str) -> Path:
return Path(str_value)
readstr('file://a,file://b', List[Path])
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
readstr-0.5.0.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file readstr-0.5.0.tar.gz
.
File metadata
- Download URL: readstr-0.5.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48be04cec13ada45c2f25e7c65fbe5a671d180a254d790eba036116c58068539 |
|
MD5 | 88e8a88ac19e3c2e0ac254a443adb83f |
|
BLAKE2b-256 | d3a807e9603dc0a42272f324f1277c36c1042013c950b499524d8a2851bda7e6 |
File details
Details for the file readstr-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: readstr-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b2aee47e4e0b45cf5682dcd438ba71d29129bdd89ae977ee357d3241ff92b2 |
|
MD5 | af5a7e1008ae03d979c8fe39a74fb01c |
|
BLAKE2b-256 | 4af06d47d099bbcb5326bb3063fb1086423a3952a29da47db0f70add20feabbb |