Skip to main content

force_kwargs

A simple Python decorator to enforce the use of keyword arguments in functions, limiting the number of positional arguments allowed.

Installation

pip install force_kwargs

Usage

Import the force_kwargs function and use it as a decorator on your functions to limit the number of positional arguments that can be passed.

You can specify the number of allowed positional arguments with the n_allowed_args parameter.

Example

from force_kwargs import force_kwargs

@force_kwargs(n_allowed_args=2)
def add(a, b, do_print):
	res = a + b
	if do_print:
		print(res)
	return res

add(1, 2, do_print=True)  # `3`.
add(1, 2, False)  # SyntaxError.

License

No License since this code is extremely basic.

Feel free to do what ever you want with this code.

:D

V0.101 released on 22th/5/2024

should now be installable??

Release files for force-kwargs 0.101

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

Source distribution (sdist)

Source distribution for force-kwargs 0.101
File Size Uploaded
force_kwargs-0.101.tar.gz 8.8 kB Details

Release files / force_kwargs-0.101.tar.gz

Download URL force_kwargs-0.101.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
708de5510e3ab5052dbdea1cb6ccb8038af12887ab064c3f1d08818a6a2c02d1
BLAKE2b-256 checksum
How to use checksums
5ed1c68240b56d97eebd3a2240f0262559464350d9c01e56a6ea872eeb060a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.101 This release

1 release file

0.1

1 release file

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