Skip to main content

Parse strings into Python types intelligently — booleans, numbers, dates, None, lists

Project description

philiprehberger-type-parse

Tests PyPI version License

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

philiprehberger_type_parse-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_type_parse-0.1.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_type_parse-0.1.3.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_type_parse-0.1.3.tar.gz
Algorithm Hash digest
SHA256 cf01e491efac3949f4874aaad64b623d789ca8958fa4786ab084ff75988e2004
MD5 ed2ac5a446823805c6ec74e339e3bf9f
BLAKE2b-256 f7105cc0f26756e4e317e98af33b3a5b4ccc881aa4b0941e5804d2f6d8ad9487

See more details on using hashes here.

File details

Details for the file philiprehberger_type_parse-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_type_parse-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3fd996d727da7871d1dc8678a93d88dae7c50a871b90da7c31566477117d381e
MD5 da28e0511ccded5a84beee7cdca69c54
BLAKE2b-256 3c55eb8eaf18294fa44e7b0215ee737b3c4b4bb36155c393b62237171da1b5b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page