Skip to main content

A decorator that modifies the arguments and keyword arguments of a function before calling it.

Tested against Windows / Python 3.11 / Anaconda

pip install argskwargsmodifier

A decorator that modifies the arguments and keyword arguments of a function before calling it.

Args:
	f_py (function, optional): Reserved for the function; do not use this argument explicitly.
	args_and_function (tuple of tuples): A tuple of tuples where each tuple contains
		an argument name and a function to transform the argument. The decorator will apply
		the specified function to each argument with a matching name. Each transformation
		function takes two arguments: the argument value and a dictionary containing all
		keyword arguments and arguments (transformed into kwargs) passed to the decorated function.

Returns:
	function: The decorated function.

Example:
	from argskwargsmodifier import change_args_kwargs
	@change_args_kwargs(
		args_and_function=(
			("arg1", lambda arg, allkwargs: arg * 2),
			("arg2", lambda arg, allkwargs: arg * 3 if arg else None),
			("arg3", lambda arg, allkwargs: arg * 5 if allkwargs.get('arg2') else arg * 50 ),
		)
	)
	def example_function(arg1, arg2=None, arg3=None):
		print(arg1, arg2, arg3)
		pass


	# Test the decorated function
	example_function(1, arg3=3)
	# Output: 2 None 150
	example_function(1, 54, arg3=3)
	# Output: 2 162 15

The `change_args_kwargs` decorator allows you to modify arguments and keyword arguments based on
the provided `args_and_function` list before invoking the decorated function. Each transformation
function in `args_and_function` receives the argument's value and a dictionary of all keyword
arguments passed to the decorated function, giving you flexibility in argument modification.

Metadata

Release files for argskwargsmodifier 0.10

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

Source distribution (sdist)

Source distribution for argskwargsmodifier 0.10
File Size Uploaded Provenance Actions
argskwargsmodifier-0.10.tar.gz 3.6 kB Without provenance Details for argskwargsmodifier-0.10.tar.gz

Built distribution (wheel)

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

Total release size: 8.9 kB

Release files / argskwargsmodifier-0.10.tar.gz

Download URL argskwargsmodifier-0.10.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd51b291ab82d2852b132432233a4457039d3259884f52659ad9c25f1e97b031
BLAKE2b-256 checksum
How to use checksums
b38ed3475b6f26fe48d070c80dca44ab5544fc4f95018ad766d27e5c9ed433ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / argskwargsmodifier-0.10-py3-none-any.whl

Download URL argskwargsmodifier-0.10-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64c0c1f0b916e105182d4cf8703f31e432137d74a14513d5fb827565b01edf81
BLAKE2b-256 checksum
How to use checksums
5f1de746634b7b8b8876e2bc7118e0d47455068f121ddc13d12fc6ddc0fbd13a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for argskwargsmodifier 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

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