Skip to main content

Predicate

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}]

Installation

This project is distributed via pip. To get started:

pip install predicate

Release files for predicate 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for predicate 0.3.0
File Interpreter ABI Platform
predicate-0.3.0-py3-none-any.whl Python 3 none any Details

Release files / predicate-0.3.0-py3-none-any.whl

Download URL predicate-0.3.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65c73bbaef7e87816455d709fc50348e3c4be1752faf2f0198616d774ff11b08
BLAKE2b-256 checksum
How to use checksums
c6fe359147098430ae32918cd13e99fce73113bdbbee9f41817480b3477ae815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page