Pre-release
This release is a pre-release and may not be stable for production use.
Match-Case Library
a.k.a. matchcaselib
Welcome to matchcaselib, an easy implementation of Python 3.10's new feature of structural pattern matching.
This project is currently in a BETA STAGE.
Installation
You can install this package by running the following command in your terminal:
pip install matchcaselib
or update it with the command
pip install --upgrade matchcaselib
Usage
from matchcaselib import match
a = input("Enter in a number: ")
a = int(a)
b = input("Enter in another number: ")
b = int(b)
with match(a, b) as m:
if(m.case(1, 1)):
print("All ones.")
if(m.case(1, 2)):
print("One and two.")
if(m.case(a, 1)):
print("The value of A can be anything! A was {} and b was 1.".format(a))
if(m.default):
print("I don't know what you mean...")
What you can do:
- Compare as many sets of variables as you would like (the amount you provide with the initialization of the class must be consistent with the amount you use for the
casemethod.) - Make a "default" response - Run a block if
defaultis true (no matches were found)
Work in Progress features:
- Multi-pattern matching (test for multiple patterns)
- Break function - leave the current match
What not to do:
- Use different amounts of variables for the class initialization and the use of the
casemethod - I don't know, there aren't many bugs right now LOL
Release files for matchcaselib 0.0.1b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| matchcaselib-0.0.1b0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matchcaselib-0.0.1b0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / matchcaselib-0.0.1b0.tar.gz
| Download URL | matchcaselib-0.0.1b0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46f62ae1a58bcb6c0a5a5087e823136e6f67a3a46e5c3acafb20dc0c13517b04
|
|
BLAKE2b-256 checksum How to use checksums |
8f269ab8bd047338481a9564ab3586a2db338e2020b811ccd72de7c4bf7985c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12
|
Release files / matchcaselib-0.0.1b0-py3-none-any.whl
| Download URL | matchcaselib-0.0.1b0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b37016f1f1860686151ade474a7df38f32a10095ec6a06956c65e42aeaf4153
|
|
BLAKE2b-256 checksum How to use checksums |
5bd55f12db8f2c895b5783960b5da74ed8e02605d29474222c2f5d9d5235c303
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12
|