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.1564588115.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27bbb839d094443e24b883cbd95913ac36b7b1376c2fb553aa74c9566c0f4444 |
|
MD5 | 401dd0684435ca6a6275404d5c507035 |
|
BLAKE2b-256 | 4ed5f8e8950a9c42452ca63b5b008fba61cc43bc53a78f0b7e788fa17cad3b61 |
Close
Hashes for FilterDict-0.2.1564588115-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f3a736a95c725fad91de309d44f074cb2f26ee1c9ae2a2cbf21ab349b4d3dcc |
|
MD5 | b6c9b330449f77c8c3a52c4f36eb1781 |
|
BLAKE2b-256 | abde4a281403f359357222fc4c6618d8d056de9c77702586554e788f00474a9b |