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.2.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.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_type_parse-0.1.2.tar.gz
Algorithm Hash digest
SHA256 57d4ab919630bb78e8645aadd393211fbe8490eb367c471fe0b104dab6906aa1
MD5 c33fd4afe94ad912214112ea81e5e760
BLAKE2b-256 35cadec6a2f01f69824f5a8800b5337384665c91a4d5376a4c2d5e5ac5e59605

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_type_parse-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e530fdadcef02bc5443299610821b4e1b459b59f2c842df2e277f8ab9009da2
MD5 0d51488519c6921a7332f2cf117cd965
BLAKE2b-256 a115a5f2f2fdd8ec06bfec4aae2ed45bbabe3378028a46d1c4165c12f6ca6cb1

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