Skip to main content

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'
>> > 

PyPI

pip install abd

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

abd-0.0.2.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distributions

abd-0.0.2-py3.9.egg (1.7 kB view hashes)

Uploaded Source

abd-0.0.2-py2.py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page