Tool for writing simple decorators
Project description
Decorum is a simple tool which aims to make it easier to write flexible and simple decorators. It can also act similarly to functools.wraps.
Typical usage looks like this:
from decorum import decorator
- class my_decorator(decorator):
- def wraps(self, f):
print “I’m returning the function! You can keep it!” return f
Decorum makes lets you write decorators in a unified way. Your decorator can be used with or without arguments, and it will work the same way.
@my_decorator def foo(x): print x
Is identical to:
@my_decorator() def foo(x): print x
Writing decorators
There are two many methods you’ll want to use in your subclassed decorators. Customize wraps to handle the decoration, and return (or not) the wrapped function, and use init to handle any optional arguments.
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 Distribution
File details
Details for the file Decorum-0.1.tar.gz
.
File metadata
- Download URL: Decorum-0.1.tar.gz
- Upload date:
- Size: 1.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaa2ff347f0f230bf068f438107464e76d53906a2d5ca02ad40b2119aeed9f10 |
|
MD5 | 21ea288e0c1575d5eb2323e9a017897d |
|
BLAKE2b-256 | 6282a013ebba9b9546281252dac6aaf4c36de8df837a681e421b9bb8acc0e7f8 |