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.1553767117.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e7dd4340103e93b9a6ffa58d19fa660abc0f96f08c5a92ec7eb390816dba845 |
|
MD5 | 8badf4b188a435696a35cdd66fb2dae5 |
|
BLAKE2b-256 | b2cd274097afe9ec9cb7b146ab857b1b993a27211b374878396590763f54c6db |
Close
Hashes for FilterDict-0.2.1553767117-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94f3adb5a91b816d0696f3f6566b941d2dde0c431f6b258b7e8577a4b08bf2fd |
|
MD5 | c4a4d5efb49fb18880cd703275a9ca58 |
|
BLAKE2b-256 | 9f66984aba6566659978a57cf3d07f46c61e20aa57eaa702672fd4fc23c7a9dd |