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.1576260577
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.1576260577.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| FilterDict-0.2.1576260577-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / FilterDict-0.2.1576260577.tar.gz
| Download URL | FilterDict-0.2.1576260577.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecaead5cb3fb0db5819dd01bc61dfc13d6fd624ca495089f5a149c692dcb4d5d
|
|
BLAKE2b-256 checksum How to use checksums |
04737477d3c4f85b1f95546029c544d265cf6415e23215fed9e813ec6f5136c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|
Release files / FilterDict-0.2.1576260577-py3-none-any.whl
| Download URL | FilterDict-0.2.1576260577-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7108867d220d40faa21b368ada2f08b80a2ca3b6036e64339372de6dd807d2ba
|
|
BLAKE2b-256 checksum How to use checksums |
ef3ad2ce0b357b2d6dbf9651bbe7c733f6a451652d7f4ff005050b1483ec6d73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|