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.1552774624.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 921db90b114f4b1c6fc16186d3896e7327e1dccd326420950d2fdd81a8fd2faf |
|
MD5 | 9d663fcf99f426f43ba0a311dd54f1c1 |
|
BLAKE2b-256 | 6b026879eb066d272d24087fac3d1e5fc19f6133acea27a9038932fb577336a1 |
Close
Hashes for FilterDict-0.2.1552774624-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb7592f6c3abe7584e207a553c43bcbce52ce6b1c2e8342f664f3fc88a64f815 |
|
MD5 | b562d052c8b50855865a3537ff7e4cb9 |
|
BLAKE2b-256 | 8ff12f1f4854c1d435d3223d37629661c2639f728a2d016ac06204393343285d |