Skip to content

Files

Latest commit

a44e540 · Sep 1, 2023

History

History

chapter03_decorator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 20, 2022
Sep 1, 2023

Chapter 3: Decorator design pattern

Decorator: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

I subclass ABC and used the @abstractmethod decorator from the abc module here but do not use any of this functionality - it just serves as documentation.

Use in Python

The python decorator syntax decorator syntax looks quite different as in python you call the decorated function and the decorating function is automatically called first whereas the decorating function must be called according to the pattern in the book.

Running the code

python coffee.py