HumbleMatch
Will Sanitize your type-checks and duck-checks for you
Install using
pip install humblematch
Github Repo at github.com/bendtherules/humblematch
Available at HumbleMatch@pypi
What the heck is it?
HumbleMatch is made to add a zing to your mundane type-checking and duck-checking code.
- Check your function arguments reliably, add more flexible signatures and most of all, have a lovely API.
- Or just sprinkle some assert checks to ensure the data is what you expect it to be at any point.
- Provide helpful debugging errors, dont just fail with cryptic errors
Impress me
Lets say we want a Point class with two init signatures - Point(x,y)
and Point([x,y])
.
Assume its __init__
signature looks like def __init__(self, x, y=None)
This is the only typechecking code you'll need for valid arguments.
from humblematch import w
assert( w([int, int]) == [x, y] or w([[int, int], None]) == [x, y] )
If you like it, please move to the Tutorials. Its a bit long, but that all the documentation youll need to know.