Skip to main content

Store data in JSON format

Project description

A simple function to generate a simple filtered dict where a dict is created based on a dictionary and a function. The returned dict contains all the kwargs if the passed function which are present in the inut dict.
This is espacially useful if you have a dict with more keys than needed to call a function or you call a function by reference and want to pass an dict as kwargs

Example:

d = dict(a=0,b=1,s1="foo",s2="bar") 
def merge_strings(s1="",s2=""):
    return s1+s2

print(merge_strings(**d))
#throws TypeError: merge_strings() got an unexpected keyword argument 'a'

print(merge_strings(**filter_dict(d,merge_strings)))
# returns foobar as expected

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

FilterDict-0.2.1575457091.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

FilterDict-0.2.1575457091-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file FilterDict-0.2.1575457091.tar.gz.

File metadata

  • Download URL: FilterDict-0.2.1575457091.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for FilterDict-0.2.1575457091.tar.gz
Algorithm Hash digest
SHA256 720fc3f812de6b537d696ed2752f260276bf551a63434316e9bb40af919151c7
MD5 05e4f02a3cfb75c233eff725022c1204
BLAKE2b-256 789ca6ef52eb071fd0618d463756f017fd4cd6ab9331e5ead389bf728eee166c

See more details on using hashes here.

File details

Details for the file FilterDict-0.2.1575457091-py3-none-any.whl.

File metadata

  • Download URL: FilterDict-0.2.1575457091-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for FilterDict-0.2.1575457091-py3-none-any.whl
Algorithm Hash digest
SHA256 c88affd64cd64ab964013786ec2407ab4efa9e7860a9290f9c353d93cc834f9d
MD5 69266dbb102d86864d2406e57838811c
BLAKE2b-256 7857fbc0bb8a077cf5e8850f1bb8d4f49cae96c6c3a33545aaa0a9cb5a56f68d

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