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.1576267222.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1958f5d0b8bb8d737bab7a585cfbcc3291fd89c583b8970669716a8a9dd509a7 |
|
MD5 | 2bdb8e9b9091034fb59bcecb1e23203d |
|
BLAKE2b-256 | 85a662f6ecfe1ac266ec7c433a0a0458c5f1c331a3a5696c98693165309a03c0 |
Close
Hashes for FilterDict-0.2.1576267222-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01a00fc2e5337842f4827e2f55f3785a322e8050d31beb01a0bbfe1b0a1ca20e |
|
MD5 | ef1d70305cd136faca1592ccff1b2df4 |
|
BLAKE2b-256 | dcc9bda1495dbcf72b097993f6f6a532f15218efa6d8f5d971c8f2918767cd67 |