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.4.0.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file readstr-0.4.0.tar.gz
.
File metadata
- Download URL: readstr-0.4.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 | 0e88ebd44b750ed3add28160bcb5fd497f3f9a87e0dba4a8532b977fb679b51f |
|
MD5 | 392b7c8981e7a14c1fe90bbf51e17b4c |
|
BLAKE2b-256 | 2f100342a2112792aa0ebb86eaa300b45f813d6e2a7eb8d2ead98eb457bc5457 |
File details
Details for the file readstr-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: readstr-0.4.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 | 78a3789d28c4ca6b04d270a194fc41aa549ae18f6fe79242dc867c4e56e01192 |
|
MD5 | 808095c5bf25df585a09cf929a087e25 |
|
BLAKE2b-256 | 295b3793b1d9af1de908d6d1c51070d00e05d32c81c6d67bff0d1ad6fe989bda |