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
Release files for FilterDict 0.2.1552776917
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| FilterDict-0.2.1552776917.tar.gz | 2.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| FilterDict-0.2.1552776917-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.8 kB
Release files / FilterDict-0.2.1552776917.tar.gz
| Download URL | FilterDict-0.2.1552776917.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdd91235dbe93697a00b441a931ef87e95c4ca733ff2a03d11dc152425c203ff
|
|
BLAKE2b-256 checksum How to use checksums |
2ed0464c135c6c1e0a6952fc484b726244e08114e58efeaa6ee52e4080151fd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Release files / FilterDict-0.2.1552776917-py3-none-any.whl
| Download URL | FilterDict-0.2.1552776917-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08cb411471e9ba72cbd22949f0eee084501e527bba54dcefc2a76ee3daa1ed2d
|
|
BLAKE2b-256 checksum How to use checksums |
f4bb617a682bc52cc66fc43bdf9a1fb7e52eaed6715fbe3eb3f5d6d22f97806b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|