Skip to main content

try_match

Pattern matching

It supports Python 2.7 and 3+

Installation

Using pip to install

pip install try-match

Usage

from try_match import Case, match, DefaultCase

### match value
try:
    match(1)
except Case(2):
    raise
except Case(1):
    print(1)
   
# => 1


### match class
try:
    match(1)
except Case(str):
    raise
except Case(int):
    print('int')
    
# => 'int'


### match range
try:
    match(10)
except Case(range(1, 5)):
    raise
except Case(range(9, 20)):
    print(range(9, 20))
    
# => range(9, 20)


### match lambda
try:
    match(2)
except Case(lambda x > 5):
    raise
except Case(lambda x < 5):
     print("x < 5")
     
# => "x < 5"


### default case
try:
    match(1)
except Case(2):
    raise
except Case(3):
    raise
except DefaultCase:
    print("default")
    
# => "default"

✨🍰✨ enjoy it

Metadata

Release files for try-match 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for try-match 0.2.0
File Size Uploaded Provenance Actions
try_match-0.2.0.tar.gz 6.1 kB Without provenance Details for try_match-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for try-match 0.2.0
File Interpreter ABI Platform Actions
try_match-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for try_match-0.2.0-py2.py3-none-any.whl

Total release size: 12.4 kB

Release files / try_match-0.2.0.tar.gz

Download URL try_match-0.2.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
96c9fdce8e34b4669c5f12f4e200f87cad574ef398cbcef33b545a8ada089010
BLAKE2b-256 checksum
How to use checksums
27b2a2c6bb4b5c736208cafd70c2621073a6e1f142d4c8d55904dd033150b2dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Linux/4.4.0-18362-Microsoft

Release files / try_match-0.2.0-py2.py3-none-any.whl

Download URL try_match-0.2.0-py2.py3-none-any.whl
Size 6.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
de8db9cb462117bcce1fef7ae9f123fb661ae24b47b9b6af936a72658bb53b23
BLAKE2b-256 checksum
How to use checksums
464228b8ac16f21f3f3f277618bba78c69df6f26c1fc69c23f9369cecbb23b30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Linux/4.4.0-18362-Microsoft

Security for try-match 0.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page