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.1552756150.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8072d48d5b68c6660899c20e4fe6071896f04b6ebdd2be1fb32c38e6178bf3 |
|
MD5 | 9ff5eb3231ad46b2499ee5b9ddc765dc |
|
BLAKE2b-256 | dda5dfd960248dd17d671d29403dd275b2c020cf3799bdc8caca937d0b6e3353 |
Close
Hashes for FilterDict-0.2.1552756150-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23e7b4130cd774861232ebb90530bb027375d60e5de5dd4ccb656dbf9919219d |
|
MD5 | 9fce0e68addbb7f2d8b80748835a18ef |
|
BLAKE2b-256 | 0593050fc9d9789138980caa1a87f9a832673db4877ee3d4d69bf1da8a5fe054 |