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.1576267316.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab2eb45886051e9e7f57ec6067129e4dd998df0048bc11c26f80d503dab682e |
|
MD5 | 8ae68bbe9a558df775aced5b12422465 |
|
BLAKE2b-256 | a7d0465c86e16c197873912e0ae062ded74f5c8516ae422f21a74719dbaefeb3 |
Close
Hashes for FilterDict-0.2.1576267316-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d4ad4cbd01900ddb55efb2933d49716cb1f1d916c959bcd4f1cf9a30d69d72 |
|
MD5 | b55a625c7c26f798d2adedbea5d2006a |
|
BLAKE2b-256 | 91a93f95dd414e9c12acbecc122e070bf7fe90ce389e183472e268b17adffef2 |