Dictionary filter
Project description
interdict
Python dictionary filter
Installation
pip install interdict
Examples
Default (inclusion False)
>>> from interdict import filter_obj
>>> obj = {'name': 'shane', 'job': {'salary': 1000000, 'role': 'master of universe'}}
>>> filter = {'name': True, 'job': {'role': True}}
>>> filter_obj(obj, filter)
{'name': 'shane', 'job': {'role': 'master of universe'}}
Inclusive (a.k.a. TMI)
>>> filter_obj(obj, filter, default=True)
{'name': 'shane', 'job': {'salary': 1000000, 'role': 'master of universe'}}
Inclusive with better filter
>>> filter = {'job': {'salary': False}}
>>> filter_obj(obj, filter, default=True)
{'name': 'shane', 'job': {'role': 'master of universe'}}
Stacked filters
>>> obj = {'name': 'shane', 'job': {'salary': 1000000, 'role': {'title': 'master of universe', 'reality': 'dumpster fire starter'}}}
>>> filter_1 = {'name': False}
>>> filter_2 = {'job': {'salary': False, 'role': {'reality': False}}}
>>> filter_obj(obj, [filter_1, filter_2], default=True)
{'job': {'role': {'title': 'master of universe'}}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
interdict-2020.11.0a3.tar.gz
(3.0 kB
view details)
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 interdict-2020.11.0a3.tar.gz.
File metadata
- Download URL: interdict-2020.11.0a3.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/4.19.128-microsoft-standard
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4580f5b8a4733254284967bee19e1bbd7a4088fedd1539fe3c99ecfff3da7906
|
|
| MD5 |
b6ab1972f179d0dfa608373dfad0a926
|
|
| BLAKE2b-256 |
4a8e8ef580736dfe198d00838353a6de36d9a81676bece6fcf0d08295610e798
|
File details
Details for the file interdict-2020.11.0a3-py3-none-any.whl.
File metadata
- Download URL: interdict-2020.11.0a3-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.5 Linux/4.19.128-microsoft-standard
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9de8f525241f875e31608c9233926bdd75454b4c5874220e123e36f0901e1eb4
|
|
| MD5 |
93aa03934f8b2d198377856d70c63a28
|
|
| BLAKE2b-256 |
d09f11138f98c012327b581094551cb9eaa1a13c596f41b282a2a2d987bde58d
|