I might seem stupid here. However, I was writing some python code, and this thing struck me. In python there are things called decorators which are denoted by @
and used "around" functions like:
class PlotABC(metaclass=ABCMeta):
@property
def figure(self):
if self._figure is None: self.__create_figure()
return self._figure
@abstractmethod
def _prepare_series(self):
pass
I also know slivers of design patterns and I know there are patterns called decorators. Then once I thought, "Hey maybe the name similarity is not a bizarre coincidence."
I have read wiki: Decorator pattern and the great answer How to make a chain of function decorators? (almost whole).
It seems to me that python's decorator semantics are really powerful and can serve to implement the design pattern. As they allow to wrap around functions and methods. Though, I am still confused, since I am inexperienced with design patterns. I also do not know a language with such a dedicated mechanism for them.
Could someone experienced in python and design patterns say if the python semantics were purposely created to create decorator patterns? Is it something more, less, or does it mean something different?
And maybe throw some light how declaring a method abstract or a property is decorating it?