matchtoolz
utilities for structural pattern matching
re.match
The Regex helper provides a convenient way to use regular expressions in Python's structural pattern matching. It allows you to match strings against regex patterns within match statements. There is als RegexBytes for bytes based regular expressions.
Example:
match Regex("hello"):
case r"world":
assert False
case r"^h.?l+o$":
assert True
case _:
assert False
__contains__
The IsIn and Contains helpers assist in membership tests.
IsIn is the "match" side helper
The IsIn helper is probably the easier to use for most use cases, but it may be less performat than Contains. IsIn checks for membership in the collection without modification, so you may be looking at O(1) for lookups.
lotr = Characters(hobbits, dwarves)
match IsIn("Frodo"):
case lotr.hobbits:
assert True
case lotr.dwarves:
assert False
case _:
assert False
Contains is the "case" side helper
Contains attempts to conver the collection to a frozenset, so for re-used lookups this will be more performant, but you have to build the set, so it isn't worth it unless the collection will be matched multiple times.
lotr = Characters(Contains(hobbits), Contains(dwarves))
match "Frodo":
case lotr.hobbits:
assert True
case lotr.dwarves:
assert False
case _:
assert False
Metadata
Release files for matchtoolz 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| matchtoolz-0.1.0.tar.gz | 11.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matchtoolz-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.2 kB
Release files / matchtoolz-0.1.0.tar.gz
| Download URL | matchtoolz-0.1.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e04dd006018aadab530c86bc9a170c18b4f32b30f032ab09f31ae468831b8fff
|
|
BLAKE2b-256 checksum How to use checksums |
3ca3e07dd77e169f1c7ccc75ffe6f8dbe5ecabca7cc97c82caf25643e1032aae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.24
|
Release files / matchtoolz-0.1.0-py3-none-any.whl
| Download URL | matchtoolz-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64e566d0b77ef07ff6d3307a53ce2c84adb2f12b6f5e0915ab56a3eb59167081
|
|
BLAKE2b-256 checksum How to use checksums |
c1e2c3788973f5732b1ad5e12eede8f2677648feed80d0b149fdee680766a754
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.24
|
Security for matchtoolz 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.