Decorator class implementation for Python
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
LICENSE
README.md
decoratorium.py
setup.py

README.md

decoratorium

Decorator class implementation for Python

Installation

pip install decoratorium

Usage

from decoratorium import decoratorium

class 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.

my_decorator_500 = my_decorator(arg2=500)

@my_decorator_500
def f1():
    print('f1')

@my_decorator_500
def f2():
    print('f2')

f1()
f2()

Authors

How to contribute

Use the decoratorium github page to post issues and questions and to send pull requests.

License

MIT License