Abstract base class for decorators
Project description
abd - Abstract Base Decorator
abd provides an AbstractBaseDecorator
class which you can inherit from to create flexible decorators.
Example
>>> from abd import ABD
>>> class Decorator(ABD):
... def invoke(self, *args, **kwargs):
... """Must write an invoke function
... invoke is called when the decorated function is called
... """
... # catch, edit and pass on the (keyword) arguments
... # that are given the the decorated function
... print('invoke is called')
... result = self.decorated_object(*args, **kwargs)
... # function has been called and result is available
... # possible to edit the result here
... return result
...
>>> @Decorator
... def func(argument):
... # some function logic ...
... return argument
...
>>> func('some text')
invoke is called
'some text'
>>>
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
abd-0.0.1.tar.gz
(9.4 kB
view hashes)