Skip to main content

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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interdict-2020.11.0a3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for interdict-2020.11.0a3.tar.gz
Algorithm Hash digest
SHA256 4580f5b8a4733254284967bee19e1bbd7a4088fedd1539fe3c99ecfff3da7906
MD5 b6ab1972f179d0dfa608373dfad0a926
BLAKE2b-256 4a8e8ef580736dfe198d00838353a6de36d9a81676bece6fcf0d08295610e798

See more details on using hashes here.

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

Hashes for interdict-2020.11.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 9de8f525241f875e31608c9233926bdd75454b4c5874220e123e36f0901e1eb4
MD5 93aa03934f8b2d198377856d70c63a28
BLAKE2b-256 d09f11138f98c012327b581094551cb9eaa1a13c596f41b282a2a2d987bde58d

See more details on using hashes here.

Supported by

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