Parse strings into Python types intelligently — booleans, numbers, dates, None, lists
Project description
philiprehberger-type-parse
Parse strings into Python types intelligently — booleans, numbers, dates, None, lists.
Install
pip install philiprehberger-type-parse
Usage
from philiprehberger_type_parse import parse
parse("true") # True
parse("42") # 42
parse("3.14") # 3.14
parse("2026-03-15") # datetime.date(2026, 3, 15)
parse("none") # None
parse("hello") # "hello"
Boolean Parsing
from philiprehberger_type_parse import parse_bool
parse_bool("yes") # True
parse_bool("off") # False
parse_bool("1") # True
Number Parsing
from philiprehberger_type_parse import parse_number
parse_number("1,234") # 1234
parse_number("$19.99") # 19.99
parse_number("50%") # 50
Date Parsing
from philiprehberger_type_parse import parse_date
parse_date("2026-03-15") # datetime.date(2026, 3, 15)
parse_date("15.03.2026", dayfirst=True) # datetime.date(2026, 3, 15)
parse_date("March 15, 2026") # datetime.date(2026, 3, 15)
List Parsing
from philiprehberger_type_parse import parse_list
parse_list("a, b, c") # ["a", "b", "c"]
parse_list("x|y|z", separator="|") # ["x", "y", "z"]
API
| Function | Description |
|---|---|
parse(value) |
Auto-detect type: None, bool, int, float, date, or str |
parse_bool(value) |
Parse true/yes/1/on/y or false/no/0/off/n |
parse_number(value) |
Parse int or float with commas, currency, percentages |
parse_date(value, *, dayfirst=False) |
Parse common date formats into datetime.date |
parse_list(value, *, separator=",") |
Split into trimmed, non-empty strings |
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_type_parse-0.1.1.tar.gz.
File metadata
- Download URL: philiprehberger_type_parse-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988ebb8e81b84d39bff9c75aa6f62dceb96ab6e0977604af6b0cb48673c24e6d
|
|
| MD5 |
79edfed0372508d85c51fa75cb3a7b0e
|
|
| BLAKE2b-256 |
7d650c86280a5c7bfad319dff1ac8b510d2ca74c2203871a7d9810820de5658f
|
File details
Details for the file philiprehberger_type_parse-0.1.1-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_type_parse-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b570bda2ae0c5683f13028362cf9232e8e8e6f455dc1e53b39cab8319fe00300
|
|
| MD5 |
da0a78c515d4df1596f19e6d9b183fa1
|
|
| BLAKE2b-256 |
d1dbe868b7ab5c3cec8f922bd59f9563fc5e610c30d1aae5f0a186e0a78f5bc7
|