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.1566386417.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19af0abcdb9dc8cacf31b4da79247cbe857d9b5b5071106df620964ece44974 |
|
MD5 | 7ab483c832a565f822998efc8f5afd93 |
|
BLAKE2b-256 | d0486f6f82127a02295e72a7031025f78805854929f2721e5f6717140b7ac438 |
Close
Hashes for FilterDict-0.2.1566386417-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b92b7a8aaa5fa91dd82670adb3f794bbe4c7ad6302430c57548abb3190442407 |
|
MD5 | c87a49045c94a371f613864073d3a656 |
|
BLAKE2b-256 | 01b156117c92e3fb5f4d4a6e6331b331a7ca5131db153b94636396fc7ae3d735 |