{ "info": { "author": "Grant Jenks", "author_email": "contact@grantjenks.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "Python Pattern Matching\n=======================\n\nPython, I love you. But I'd like you to change. It's not you, it's me. Really.\nSee, you don't have pattern matching. But, that's not the root of it. Macros\nare the root of it. You don't have macros but that's OK. Right now, I want\npattern matching. I know you offer me ``if``/``elif``/``else`` statements but I\nneed more. I'm going to abuse your functions. Guido, et al, I hope you can\nforgive me. This will only hurt a little.\n\n`Python Pattern Matching`_ is an Apache2 licensed Python module for `pattern\nmatching`_ like that found in functional programming languages. Most projects\nthat address Python pattern matching focus on syntax and simple cases. Operator\noverloading is often used to change the semantics of operators to support\npattern matching. In other cases, function decorators are used to implement\nmultiple dispatch, sometimes known as function overloading. Each of these\nsyntaxes, operators, and decorators, is really more of a detail in the\napplication of pattern matching.\n\nA lot of people have tried to make this work before. Somehow it didn't take. I\nshould probably call this yet-another-python-pattern-matching-module but\n\"yappmm\" doesn't roll off the tongue. Other people have tried overloading\noperators and changing codecs. This module started as a codec hack but those are\nhard because they need an ecosystem of emacs-modes, vim-modes and the like to\nreally be convenient.\n\nPython Pattern Matching focuses instead on the semantics of pattern matching in\nPython. The dynamic duck-typing behavior in Python is distinct from the tagged\nunions found in functional programming languages. Rather than trying to emulate\nthe behavior of functional pattern matching, this project attempts to implement\npattern matching that looks and feels native to Python. In doing so the\ntraditional function call is used as syntax. There are no import hooks, no\ncodecs, no AST transforms.\n\n.. todo::\n\n Python ``match`` function example.\n\nFinally, pythonic pattern matching! If you've experienced the feature before in\n\"functional\" languages like Erlang, Haskell, Clojure, F#, OCaml, etc. then you\ncan guess at the semantics.\n\n.. todo::\n\n Show the same code without ``patternmatching``.\n\n\nFeatures\n--------\n\n- Pure-Python\n- Developed on Python 3.7\n- Tested on CPython 3.4, 3.5, 3.6, 3.7 and PyPy3\n\n.. todo::\n\n - Fully Documented\n - 100% test coverage\n - Hours of stress testing\n\n .. image:: https://api.travis-ci.org/grantjenks/python-pattern-matching.svg?branch=master\n :target: http://www.grantjenks.com/docs/patternmatching/\n\n .. image:: https://ci.appveyor.com/api/projects/status/github/grantjenks/python-pattern-matching?branch=master&svg=true\n :target: http://www.grantjenks.com/docs/patternmatching/\n\n\nQuickstart\n----------\n\nInstalling `Python Pattern Matching`_ is simple with `pip\n`_::\n\n $ pip install patternmatching\n\nYou can access documentation in the interpreter with Python's built-in `help`\nfunction. The `help` works on modules, classes, and functions in `pattern\nmatching`_.\n\n.. code-block:: python\n\n >>> from pypatt import match, bind, bound, like\n >>> help(match)\n\n\nAlternative Packages\n--------------------\n\n- https://github.com/lihaoyi/macropy\n - module import, but similar design\n- https://github.com/Suor/patterns\n - decorator with funky syntax\n - Shared at Python Brazil 2013\n- https://github.com/mariusae/match\n - http://monkey.org/~marius/pattern-matching-in-python.html\n - operator overloading\n- http://blog.chadselph.com/adding-functional-style-pattern-matching-to-python.html\n - multi-methods\n- http://svn.colorstudy.com/home/ianb/recipes/patmatch.py\n - multi-methods\n- http://www.artima.com/weblogs/viewpost.jsp?thread=101605\n - the original multi-methods\n- http://speak.codebunk.com/post/77084204957/pattern-matching-in-python\n - multi-methods supporting callables\n- http://www.aclevername.com/projects/splarnektity/\n - not sure how it works but the syntax leaves a lot to be desired\n- https://github.com/martinblech/pyfpm\n - multi-dispatch with string parsing\n- https://github.com/jldupont/pyfnc\n - multi-dispatch\n- http://www.pyret.org/\n - It's own language\n- https://pypi.python.org/pypi/PEAK-Rules\n - generic multi-dispatch style for business rules\n- http://home.in.tum.de/~bayerj/patternmatch.py\n - Pattern-object idea (no binding)\n- https://github.com/admk/patmat\n - multi-dispatch style\n\n\nOther Languages\n---------------\n\n- https://msdn.microsoft.com/en-us/library/dd547125.aspx F#\n- https://doc.rust-lang.org/book/patterns.html Rust\n- https://www.haskell.org/tutorial/patterns.html Haskell\n- http://erlang.org/doc/reference_manual/expressions.html#pattern Erlang\n- https://ocaml.org/learn/tutorials/data_types_and_matching.html Ocaml\n\n\nDeveloper Guide\n---------------\n\n* `Python Pattern Matching Tutorial`_\n* `Python Pattern Matching Reference`_\n* `Python Pattern Matching Search`_\n* `Python Pattern Matching Index`_\n\n.. _`Python Pattern Matching Tutorial`: http://www.grantjenks.com/docs/patternmatching/tutorial.html\n.. _`Python Pattern Matching Reference`: http://www.grantjenks.com/docs/patternmatching/reference.html\n.. _`Python Pattern Matching Search`: http://www.grantjenks.com/docs/patternmatching/search.html\n.. _`Python Pattern Matching Index`: http://www.grantjenks.com/docs/patternmatching/genindex.html\n\n\nProject Links\n-------------\n\n* `Python Pattern Matching`_\n* `Python Pattern Matching at PyPI`_\n* `Python Pattern Matching at GitHub`_\n* `Python Pattern Matching Issue Tracker`_\n\n.. _`Python Pattern Matching`: http://www.grantjenks.com/docs/patternmatching/\n.. _`Python Pattern Matching at PyPI`: https://pypi.python.org/pypi/patternmatching/\n.. _`Python Pattern Matching at GitHub`: https://github.com/grantjenks/python-pattern-matching\n.. _`Python Pattern Matching Issue Tracker`: https://github.com/grantjenks/python-pattern-matching/issues\n\n\nPython Pattern Matching License\n-------------------------------\n\nCopyright 2015-2019, Grant Jenks\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n\n.. _`pattern matching`: http://www.grantjenks.com/docs/patternmatching/\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.grantjenks.com/docs/patternmatching/", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "patternmatching", "package_url": "https://pypi.org/project/patternmatching/", "platform": "", "project_url": "https://pypi.org/project/patternmatching/", "project_urls": { "Homepage": "http://www.grantjenks.com/docs/patternmatching/" }, "release_url": "https://pypi.org/project/patternmatching/3.0.1/", "requires_dist": null, "requires_python": "", "summary": "Python Pattern Matching", "version": "3.0.1" }, "last_serial": 4687899, "releases": { "3.0.1": [ { "comment_text": "", "digests": { "md5": "ef4de1a88b8fa833ead812cd9c17ae77", "sha256": "dceaf55aee83c03f635b6b1d85c6a36b2b343a4688e5e61cb3363ae2d1d62537" }, "downloads": -1, "filename": "patternmatching-3.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ef4de1a88b8fa833ead812cd9c17ae77", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10224, "upload_time": "2019-01-12T06:35:30", "url": "https://files.pythonhosted.org/packages/32/87/55e27db41dbd465ca7355a7e7763b4297b3a6e4d71323fc127e4961cf29c/patternmatching-3.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cbf2e91f1121754040b00d0dd81fdd95", "sha256": "1cce8c7b9fe4d67951a5be2d21b120ab3bc61acb47a987fa34cfe2599aa1be49" }, "downloads": -1, "filename": "patternmatching-3.0.1.tar.gz", "has_sig": false, "md5_digest": "cbf2e91f1121754040b00d0dd81fdd95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12796, "upload_time": "2019-01-12T06:35:32", "url": "https://files.pythonhosted.org/packages/5e/44/6c158def74e48d0de2d32c1256f2792dafad3e586d97f2335af59f661669/patternmatching-3.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ef4de1a88b8fa833ead812cd9c17ae77", "sha256": "dceaf55aee83c03f635b6b1d85c6a36b2b343a4688e5e61cb3363ae2d1d62537" }, "downloads": -1, "filename": "patternmatching-3.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ef4de1a88b8fa833ead812cd9c17ae77", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10224, "upload_time": "2019-01-12T06:35:30", "url": "https://files.pythonhosted.org/packages/32/87/55e27db41dbd465ca7355a7e7763b4297b3a6e4d71323fc127e4961cf29c/patternmatching-3.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cbf2e91f1121754040b00d0dd81fdd95", "sha256": "1cce8c7b9fe4d67951a5be2d21b120ab3bc61acb47a987fa34cfe2599aa1be49" }, "downloads": -1, "filename": "patternmatching-3.0.1.tar.gz", "has_sig": false, "md5_digest": "cbf2e91f1121754040b00d0dd81fdd95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12796, "upload_time": "2019-01-12T06:35:32", "url": "https://files.pythonhosted.org/packages/5e/44/6c158def74e48d0de2d32c1256f2792dafad3e586d97f2335af59f661669/patternmatching-3.0.1.tar.gz" } ] }