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.8.0.tar.gz
(8.2 kB
view details)
Built Distribution
File details
Details for the file readstr-0.8.0.tar.gz
.
File metadata
- Download URL: readstr-0.8.0.tar.gz
- Upload date:
- Size: 8.2 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.62.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bb09fd8adcd6cce4226e7eb6a5dbe9f67d090f50ede642a7cb2011489cef6a5 |
|
MD5 | 40aaf0e1ec6d174d102386228d6fdb79 |
|
BLAKE2b-256 | f8f8cfebc4f73b8b61933b83a36491e30c23c0c86dbe411fa5924f1f5ed55f69 |
File details
Details for the file readstr-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: readstr-0.8.0-py3-none-any.whl
- Upload date:
- Size: 9.2 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.62.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23fe529699ccbb58378094ee6e0906701ecfe6e8d5f25b2b8ecea6b9f04e9379 |
|
MD5 | 4b04881d442f41d1dadd5729efff70b1 |
|
BLAKE2b-256 | f4ac3ae22be0af7f1cf1d8c0c88a8cb5908a3f85ff83e396a6f1cd5ff4d7f321 |