{"id":23840423,"url":"https://github.com/admk/patmat","last_synced_at":"2025-09-07T17:31:43.541Z","repository":{"id":11646490,"uuid":"14152255","full_name":"admk/patmat","owner":"admk","description":"Functional-style recursive pattern matching in Python. Crazy stuff.","archived":false,"fork":false,"pushed_at":"2016-05-23T12:51:20.000Z","size":14,"stargazers_count":29,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-04T12:02:52.964Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/admk.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-05T19:53:35.000Z","updated_at":"2024-10-01T19:16:58.000Z","dependencies_parsed_at":"2022-09-06T10:20:52.923Z","dependency_job_id":null,"html_url":"https://github.com/admk/patmat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/admk/patmat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admk%2Fpatmat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admk%2Fpatmat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admk%2Fpatmat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admk%2Fpatmat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/admk","download_url":"https://codeload.github.com/admk/patmat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admk%2Fpatmat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274068091,"owners_count":25216845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T17:49:09.437Z","updated_at":"2025-09-07T17:31:43.230Z","avatar_url":"https://github.com/admk.png","language":"Python","readme":"patmat\n======\n\nFunctional-style recursive pattern matching in Python. Crazy stuff.\n\n\nInstall\n-------\n.. code-block:: sh\n\n    pip install patmat\n\n\nUsage\n-----\n\nPattern matching with `patmat`:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from patmat import *\n    \u003e\u003e\u003e Mimic({(1, Val('k')): (3, Val('v'))}).match({(1, 2): (3, 4)})\n    {'k': 2, 'v': 4}\n\nMultiple dispatch generic functions:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from patmat import *\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e @case\n    \u003e\u003e\u003e def func(match, l=[Val('head'), ..., 3, Val('tail')]):\n    ...     print('a list with a head {} and a tail {}'.format(match.head, match.tail))\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e @case\n    \u003e\u003e\u003e def func(match, l=Val('item')):\n    ...     print('an item {}'.format(match.item))\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e func([1, 2, 3, 4])\n    a list with a head 1 and a tail 4\n    \u003e\u003e\u003e func(5)\n    an item: 5\n\nMore dispatch examples:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e @case\n    \u003e\u003e\u003e def func(_, x=int):\n    ...     print('Do something with an integer.')\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e @case\n    \u003e\u003e\u003e def func(_, x=float):\n    ...     print('Do something with a float.')\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e func(1)\n    Do something with an integer\n    \u003e\u003e\u003e func(1.0)\n    Do something with a float\n\nMatches ``list``, ``tuple``, ``dict``, types, classes with attributes. Brace\nyourself for the power of recursive pattern matching:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from patmat import *\n    \u003e\u003e\u003e m = Mimic([\n    ...     1, Type(int, Val(2)),\n    ...     Mimic(a=3, b=[4, Val(5), 6], c=Val(7)),\n    ...     Val(8), {Val(9): 10, Val(11): 12},\n    ... ])\n    \u003e\u003e\u003e class A: \n    ...     __init__ = lambda self, **kwargs: self.__dict__.update(kwargs)\n    \u003e\u003e\u003e m.match([1, 2, A(a=3, b=[4, 5, 6], c=7), 8, {9: 10, 11: 12}])\n    {2: 2, 5: 5, 7: 7, 8: 8, 9: 9, 11: 11}\n\n\n.. image:: https://d2weczhvl823v0.cloudfront.net/admk/patmat/trend.png\n   :alt: Bitdeli badge\n   :target: https://bitdeli.com/free\n\n","funding_links":[],"categories":["Awesome Functional Python"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmk%2Fpatmat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadmk%2Fpatmat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmk%2Fpatmat/lists"}