2

The term decorator appears in Python, and now in Angular2 as well.

In Python, does it mean the decorator design pattern as in the book Design Patterns by GoF, or does it mean something else? (such as something just to annotate, like Java annotation?)

nonopolarity
  • 146,324
  • 131
  • 460
  • 740

1 Answers1

0

In Python, Decorators provide a simple syntax for calling higher-order functions. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.

Read below link to have full understanding about Python decorators.

https://realpython.com/blog/python/primer-on-python-decorators/

Hassan Mehmood
  • 1,414
  • 1
  • 14
  • 22
  • 1
    so that's very close to the OOP decorator... just except that OOP decorator are 2 classes, while functional decorator is about 2 functions... both are the same concept that one absorbs the other and providing the exact same interface – nonopolarity Apr 19 '16 at 11:27
  • Yes, both having similar concept – Hassan Mehmood Apr 19 '16 at 11:30