Skip to main content

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))

Metadata

Release files for chocolate 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chocolate 0.0.2
File Size Uploaded
chocolate-0.0.2.tar.gz 1.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chocolate 0.0.2
File Interpreter ABI Platform
chocolate-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 3.7 kB

Release files / chocolate-0.0.2.tar.gz

Download URL chocolate-0.0.2.tar.gz
Size 1.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3474af447e11c592635afae2578d8f425351045949dc1c2fd3a98dd859b5816c
BLAKE2b-256 checksum
How to use checksums
346afb1e15a5335e53024a0b021cca740a5ae7b68f78586c20bed5b0938218fa
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / chocolate-0.0.2-py3-none-any.whl

Download URL chocolate-0.0.2-py3-none-any.whl
Size 2.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
071ea6177492d80c903eb6c7c30638a2d97d9561ace40b7b5c3f2b220c3a246e
BLAKE2b-256 checksum
How to use checksums
ecdf206fea3fbad2b8c709f9bad919515aa7658b631dd95e7de49978343d7007
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page