Skip to main content

Paramdec is a convenient way to create parametrized decorators.

Usage

Create your parametrized decorator:

>>> from paramdec import paramdec
>>> @paramdec
... def my_dec(func, foo=42, bar=None):
...     def wrapper(*func_args, **func_kwargs):
...         # Process foo and bar
...         return func(*func_args, **func_kwargs)
...     return wrapper

Use it with parameters:

>>> @my_dec(bar="bar")
>>> def func(): pass

Or without parameters:

>>> @my_dec()
>>> def func(): pass

Or even without parentheses:

>>> @my_dec
>>> def func(): pass

Also, consider using functools.wraps for your decorators.

Limitations

  • No positional args supported.

The rationale behind this is the fact that I have not found any pythonic way to make a decorator differentiate between a function to be decorated and a callback. So if you pass a single callable positional argument to a parametrized decorator, it will mistakenly decide that it was called not as a factory but as a casual decorator.

Metadata

Release files for paramdec 2.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for paramdec 2.1.0
File Interpreter ABI Platform Actions
paramdec-2.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for paramdec-2.1.0-py2.py3-none-any.whl

Release files / paramdec-2.1.0-py2.py3-none-any.whl

Download URL paramdec-2.1.0-py2.py3-none-any.whl
Size 4.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
717a07551182ca16dc45d30b207dd8cd3706da9998ac3ec7f06ea81d77d34206
BLAKE2b-256 checksum
How to use checksums
a98cc59390dfbb53f858d1b6b7217f74163b90c588f195b11121a61108120033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for paramdec 2.1.0

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

2.1.0 This release

1 release file 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