Simple and useful decorator utilities.
Project description
decorator-utils
Installation
python3 -m pip install decorator-utils
Usage
from random import randint
from decorator_utils import function_wrapper
@function_wrapper(pre_cb=lambda i: print(f'Calling with param {i}'),
post_cb=lambda r, i: print(f'Function call result `{r}` with param `{i}`'))
def random_int(increment):
number = randint(0, 10)
print(f'-> Generated number {number}')
return number + increment
if __name__ == '__main__':
n = randint(0, 10)
random_int(n)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
decorator_utils-1.1.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for decorator_utils-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f4c975515d80c4f5483ad6cf0cd27a9315f89a15a2c806cc8b7403a824c436 |
|
MD5 | 8971cbaaf28992f99cafec1edbcaaf64 |
|
BLAKE2b-256 | b8074d62bd7d4eea12431697dd0eed97ef4300e9ce29adbf11f78f1dfb6655cc |