Skip to main content

Predicate Functions for Python in the style of django filters

Project description


PyPI version pipeline status coverage report PyPI Documentation Status

Predicate takes the django queryset filtering language and applies it to building python native predicate functions that you can pass to the filter builtin.

This library is mean to make creating native python filter functions readable and easy:

>>> from predicate import where

>>> people = [
...     {'name': {'first': 'Joe', 'last': 'Smith'}, 'age': 25},
...     {'name': {'first': 'Jane', 'last': 'Smith'}, 'age': 27},
...     {'name': {'first': 'John', 'last': 'Smith'}, 'age': 33},
...     {'name': {'first': 'Bill', 'last': 'Bob'}, 'age': 40},
...     {'name': {'first': 'Joe', 'last': 'Bob'}, 'age': 59},
... ]

>>> young_smiths = list(filter(where(name__last__iexact='smith', age__lte=30), people))

>>> young_smiths
[{'name': {'first': 'Joe', 'last': 'Smith'}, 'age': 25}, {'name': {'first': 'Jane', 'last': 'Smith'}, 'age': 27}]


This project is distributed via pip. To get started:

pip install predicate

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

predicate-0.3.0-py3-none-any.whl (6.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page