An improvement to Python's kwargs
Project description
Chocolate
Chocolate is a Python package that improves Python's **kwargs.
from chocolate import filter_args
# Here is some function.
def example_function(arg1, arg2: int, arg3=3, arg4: str = ""):
print(f"{arg1} {arg2} {arg3} {arg4}")
# We can give this function a dictionary of arguments using **kwargs.
kwargs = {"arg1": 1, "arg2": 2, "arg4": "4"}
example_function(**kwargs)
# But what if the **kwargs dictionary has additional keys?
broken_kwargs = {"arg1": "This", "arg2": "does", "undefined_arg": "not", "arg3": "work"}
try:
example_function(**broken_kwargs)
except Exception as exception:
print(exception)
# Chocolate can take care of that!
example_function(**filter_args(broken_kwargs, example_function))
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
chocolate-0.0.2.tar.gz
(1.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chocolate-0.0.2.tar.gz.
File metadata
- Download URL: chocolate-0.0.2.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3474af447e11c592635afae2578d8f425351045949dc1c2fd3a98dd859b5816c
|
|
| MD5 |
03c04aa18c0f6240581a3c815de50882
|
|
| BLAKE2b-256 |
346afb1e15a5335e53024a0b021cca740a5ae7b68f78586c20bed5b0938218fa
|
File details
Details for the file chocolate-0.0.2-py3-none-any.whl.
File metadata
- Download URL: chocolate-0.0.2-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
071ea6177492d80c903eb6c7c30638a2d97d9561ace40b7b5c3f2b220c3a246e
|
|
| MD5 |
b050388a94eb1d84559ba3b91ea9d3fc
|
|
| BLAKE2b-256 |
ecdf206fea3fbad2b8c709f9bad919515aa7658b631dd95e7de49978343d7007
|