Skip to main content

Predicate Functions for Python in the style of django filters

Project description

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

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 details)

Uploaded Python 3

File details

Details for the file predicate-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: predicate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for predicate-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65c73bbaef7e87816455d709fc50348e3c4be1752faf2f0198616d774ff11b08
MD5 97e152e01967d28bf7257be88cc29ab5
BLAKE2b-256 c6fe359147098430ae32918cd13e99fce73113bdbbee9f41817480b3477ae815

See more details on using hashes here.

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