Skip to main content

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

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.1553766478.tar.gz (2.2 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.1553766478-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: FilterDict-0.2.1553766478.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for FilterDict-0.2.1553766478.tar.gz
Algorithm Hash digest
SHA256 991d2e97d44abb8ffa26b5a6ee4e75392f630bb859985ee97910afa288db9e72
MD5 25e157f7009cd3c1e2d9283fbb1a8d3a
BLAKE2b-256 41dc73ad2040a2c8e5e632405095f0e792e9cb2b6fffcd26eeb5cb49d1d7ed21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: FilterDict-0.2.1553766478-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for FilterDict-0.2.1553766478-py3-none-any.whl
Algorithm Hash digest
SHA256 5a29a2a8b7e0c580e6269c0c75f66fe9b30ef499868118ba466d62788f2b874e
MD5 b33047a21bae6cd6609ba0b50221e14c
BLAKE2b-256 768c8c6f536d878881737b0a166edb70872b69ec8706083e131321c821915a56

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1576267427

2 files

0.2.1576267316

2 files

0.2.1576267222

2 files

0.2.1576260577

2 files

0.2.1566386417

2 files

0.2.1564588115

2 files

0.2.1553767117

2 files

This release

0.2.1553766478 This release

2 files

0.2.1552776917

2 files

0.2.1552774624

2 files

0.2.1552756581

2 files

0.2.1552756360

2 files

0.2.1552756150

2 files

Supported by

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