Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lig/decoratorium
Decorator class implementation for Python
https://github.com/lig/decoratorium
decorator decorators library python python3
Last synced: about 2 months ago
JSON representation
Decorator class implementation for Python
- Host: GitHub
- URL: https://github.com/lig/decoratorium
- Owner: lig
- License: mit
- Created: 2017-03-02T12:08:29.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-03-03T10:38:24.000Z (almost 8 years ago)
- Last Synced: 2024-11-01T15:51:46.945Z (about 2 months ago)
- Topics: decorator, decorators, library, python, python3
- Language: Python
- Size: 7.81 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# decoratorium
Decorator class implementation for Python
## Installation
```shell
pip install decoratorium
```## Usage
```python
from decoratorium import decoratoriumclass my_decorator(decoratorium):
def __init__(self, arg1=100, arg2=200):
self.arg1 = arg1
self.arg2 = arg2
def wrapper(self, func, *args, **kwargs):
result = func(*args, **kwargs)
return self.arg1 * self.arg2 / result@my_decorator
def f1():
pass@my_decorator()
def f2():
pass@my_decorator(arg2=500)
def f3():
pass
```It is safe to reuse the same once created decorator instance on a different
functions.```python
my_decorator_500 = my_decorator(arg2=500)@my_decorator_500
def f1():
print('f1')@my_decorator_500
def f2():
print('f2')f1()
f2()
```## Authors
* [Serge Matveenko](https://github.com/lig)
## How to contribute
Use [the decoratorium github page](https://github.com/lig/decoratorium) to post issues and questions and to send pull requests.
## License
[MIT License](LICENSE)