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.1575448033.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 032c109d20463aedf8dbaa00c440dbb7050476f12f407a7cd24b0cd1c90a2066 |
|
MD5 | b00a36bda31095a0512fbeeae15b6216 |
|
BLAKE2b-256 | 51c98065d41d6cb4fd657c3cdabc4b89550796398cfa3c6cc07f4deff8a65a1c |
Close
Hashes for FilterDict-0.2.1575448033-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ac878252fbc10cdc80be380ef4b5e52a7e2ac8249537997db935fda2b5ebcc5 |
|
MD5 | 57e84664e10e665a79de8d65b9666489 |
|
BLAKE2b-256 | 8c8781334290401c5bb7b8f62760504166ab48d416fd9e6c980463a3dbc41c85 |