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
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
Built Distribution
Close
Hashes for FilterDict-0.2.1552756360.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c600e094895a494a30b2d1e94bfef737327620cd5feefffa87ed144df555078 |
|
MD5 | 6f790700950bfbe17da773ffb624505a |
|
BLAKE2b-256 | e1599d814cdffadddc90274db0b9319ae9aa0aada76adf1f9e044c8325644ba6 |
Close
Hashes for FilterDict-0.2.1552756360-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f0bee932fff7669cbb4161a1830366c07933a6cee32caead662c8dd8bc28b61 |
|
MD5 | 2658dbd3ab7d264e52264a79212d90a5 |
|
BLAKE2b-256 | 5264d3a2f4f240982fcab80f609026173d5d0d93634776397d7ba96eace5ad22 |