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.1576267427.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2796e3c9964987eeb6704ccaceff904cc921d3e32505501ec94e44905d004e40 |
|
MD5 | 04727744dd6cda86b4ecc5babd009bca |
|
BLAKE2b-256 | c137589cce2468c60d71519aeaf5174bfd5d55d26c0be9355a1429423381589d |
Close
Hashes for FilterDict-0.2.1576267427-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 659e9405c9bc3eddefc06a41778513a53c6fd3b7a4a953c399c02d2684fd490e |
|
MD5 | 7e9301203a2cea3eebd61d75e3ea45fe |
|
BLAKE2b-256 | 938c05b2c1c39b664fe6500fb51d1ae43e2447f5c8075647dec9c7577ee5e72b |