Skip to content
develop
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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

About

Decorator class implementation for Python

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.