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.1552756581.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e10e49b8e5b5b341f80372abcd4a21a3724f8cacba7e9f018f4b46c326c9f06d |
|
MD5 | dfbbf903a653eb9efefb193bbc35c68c |
|
BLAKE2b-256 | d30256e0f6887e3530906f3a8bbd51fc78a4b82083d672e4d457c57d72abe118 |
Close
Hashes for FilterDict-0.2.1552756581-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0de7f516840b20c5db320ad3ef01e799796e8a061c6eda7804a7c8fc56987a2c |
|
MD5 | 609017ab007576a7d77014b9e24d61fc |
|
BLAKE2b-256 | a837cdf09ccd275126be204bed804dc5d4bce654cf7babb0142a833031f7ef25 |