Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Natch

Pattern matching library.

PyPI Version Docs Status GitHub MIT License


Overview

Natch enables, but is not limited to, pattern matching in function headers with single or multi arities, by supporting linear or nested lookups including logical expressions; can be expanded by writing custom rule classes.

Conditional function headers:

@natch.lt(0)
def f(x):
  return f(x * -1)


@natch.gte(0)
def f(x):
  return x + 1


>>> f(-1)
>>> 2

See more examples.

Installing

Natch can be installed and updated using pip.

$ pip install -U natch

Troubleshooting

Python has a platform-dependent recursion limit. If your software requires too many nested function calls, it is recommended to avoid using recursive functions.

If you still need to follow recursive approach, you may need to set recursion limit as necessary.

You can’t perform that action at this time.