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.1.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.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file interdict-2020.11.1.tar.gz.

File metadata

  • Download URL: interdict-2020.11.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a7e671cb9c44991b86b1feb6b309d43f92fde6313876e3fcd615724cb9fbdf1b
MD5 ad12422b9d3c23899fe77ea95a6cd065
BLAKE2b-256 d80accfafea0f394b139e3598369b370c6f6503c45e22c4d6aa024a910dc5cf8

See more details on using hashes here.

File details

Details for the file interdict-2020.11.1-py3-none-any.whl.

File metadata

  • Download URL: interdict-2020.11.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 937b6b304b34b0f8ae0451e4288914c157876de4080c3d51abcafbc108aab88a
MD5 fed4124d9b6332be9ff17c3c7863ce5f
BLAKE2b-256 b1b3d784d51b16a5d35e70bdd389e1e00dbcda70af12301551ccd092baeb9a6d

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