This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Functional-style recursive pattern matching in Python. Crazy stuff.

Install

pip install patmat

Usage

Pattern matching with patmat:

>>> from patmat import *
>>> Mimic({(1, Val('k')): (3, Val('v'))}).match({(1, 2): (3, 4)})
{'k': 2, 'v': 4}

Multiple dispatch generic functions:

>>> from patmat import *
>>>
>>> @case
>>> def func(match, l=[Val('head'), ..., 3, Val('tail')]):
...     print('a list with a head {} and a tail {}'.format(match.head, match.tail))
>>>
>>> @case
>>> def func(match, l=Val('item')):
...     print('an item {}'.format(match.item))
>>>
>>> func([1, 2, 3, 4])
a list with a head 1 and a tail 4
>>> func(5)
an item: 5

More dispatch examples:

>>> @case
>>> def func(_, x=int):
...     print('Do something with an integer.')
>>>
>>> @case
>>> def func(_, x=float):
...     print('Do something with a float.')
>>>
>>> func(1)
Do something with an integer
>>> func(1.0)
Do something with a float

Matches list, tuple, dict, types, classes with attributes. Brace yourself for the power of recursive pattern matching:

>>> from patmat import *
>>> m = Mimic([
...     1, Type(int, Val(2)),
...     Mimic(a=3, b=[4, Val(5), 6], c=Val(7)),
...     Val(8), {Val(9): 10, Val(11): 12},
... ])
>>> class A:
...     __init__ = lambda self, **kwargs: self.__dict__.update(kwargs)
>>> m.match([1, 2, A(a=3, b=[4, 5, 6], c=7), 8, {9: 10, 11: 12}])
{2: 2, 5: 5, 7: 7, 8: 8, 9: 9, 11: 11}
Release History

Release History

1.0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
patmat-1.0.1.tar.gz (5.7 kB) Copy SHA256 Checksum SHA256 Source Nov 6, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting