Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/w13b3/abstract_base_decorator
Abstract base class for creating for both python classes and function decorators
https://github.com/w13b3/abstract_base_decorator
abstract-factory-pattern baseclass class-decorator decorator decorator-pattern inheritance oop python
Last synced: 8 days ago
JSON representation
Abstract base class for creating for both python classes and function decorators
- Host: GitHub
- URL: https://github.com/w13b3/abstract_base_decorator
- Owner: w13b3
- License: mpl-2.0
- Created: 2021-06-24T20:40:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-01T06:47:07.000Z (over 3 years ago)
- Last Synced: 2023-11-20T16:03:56.173Z (about 1 year ago)
- Topics: abstract-factory-pattern, baseclass, class-decorator, decorator, decorator-pattern, inheritance, oop, python
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
abd - Abstract Base Decorator
---abd provides an `AbstractBaseDecorator` class which you can inherit from to create flexible decorators.
## Example
```Python3
>>> 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](https://pypi.org/project/abd/ "PyPI abd page")