Skip to main content

Easy peasy Python decorators

Project description

Easy-peasy Python decorators!

Work in Progress!

Summary

Decorators are great, but they’re hard to write, especially if you want to include arguments to your decorators, or use your decorators on classes as well as functions, or if you want to be able to call your decorators with or without parentheses.

PyDecor aims to make function easy and straightforward, so that developers can stop worrying about closures and syntax in triply nested functions and instead get down to decorating!

Planned Featureset

My plan is to include the following callback-oriented decorators. All decorators will be capable of functioning at the function, method, or class level. Decorators will be stackable.

  • before - run a callback before the decorated callable, optionally introspecting and altering the args and kwargs passed to the decorated function

  • after - run a callback after the decorated callable, optionally introspecting and adjusting/replacing the return value

  • decorate - allow providing before and after functions in one decorator rather than stacking

In addition, a function decorator will be provided, which will take similar arguments to decorate above, but will instead return a new decorator. Decorators created in this way will be callable at the function, method, or the class level, with or without parameters, and will be stackable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pydecor-0.1.0.dev3-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pydecor-0.1.0.dev3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pydecor-0.1.0.dev3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3233127d6f4f96285deaa6b2e551bd07261566acc75131f0298a7b4ef21d0a0b
MD5 fe67d6828ff2efe7a5b96492f88adfbc
BLAKE2b-256 be1f8ed7e83df54b414c4064f34e8dbc4a6498f7686ea2580a1f9587aacca2b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page