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

Uploaded Python 2 Python 3

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