Predicate Functions for Python in the style of django filters
Project description
Predicate
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c73bbaef7e87816455d709fc50348e3c4be1752faf2f0198616d774ff11b08
|
|
| MD5 |
97e152e01967d28bf7257be88cc29ab5
|
|
| BLAKE2b-256 |
c6fe359147098430ae32918cd13e99fce73113bdbbee9f41817480b3477ae815
|