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.
Credits and Links
This project was started using my semi-custom project template
Tests are run with pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file pydecor-0.1.0.dev3-py2.py3-none-any.whl
.
File metadata
- Download URL: pydecor-0.1.0.dev3-py2.py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3233127d6f4f96285deaa6b2e551bd07261566acc75131f0298a7b4ef21d0a0b |
|
MD5 | fe67d6828ff2efe7a5b96492f88adfbc |
|
BLAKE2b-256 | be1f8ed7e83df54b414c4064f34e8dbc4a6498f7686ea2580a1f9587aacca2b7 |