pguard

Guard like Haskell for Python.

Status

https://secure.travis-ci.org/mkouhei/pguard.png?branch=master https://coveralls.io/repos/mkouhei/pguard/badge.png?branch=master https://img.shields.io/pypi/v/pguard.svg Documentation Status

Requirements

  • Python 2.7 or Python 3.5 over or PyPy 2.4.0 over

Features

  • guard with lambda
  • Enable to use function or method as guard_cl statement argument.

Setup

$ pip install --user pguard
or
(venv)$ pip install pguard

Simple usage

>>> from pguard import guard
>>> from pguard import guard_cl as g
>>> (lambda n: guard(
... g(-1, n < 0),
... g(0, n == 0),
... g(1)  ## otherwise
... ))(0)
0