A Gentle Introduction to Decorators in Python

When working on code, whether we know it or not, we often come across the decorator design pattern. This is a programming technique to extend the functionality of classes or functions without modifying them. The decorator design pattern allows us to mix and match extensions easily. Python has a decorator syntax rooted in the decorator design pattern. Knowing how to make and use a decorator can help you write more powerful code.

In this post, you will discover the decorator pattern and Python’s function decorators.

After completing this tutorial, you will learn:

  • What is the decorator pattern, and why is it useful
  • Python’s function decorators and how to use them

Kick-start your project with my new book Python

 

 

To finish reading, please visit source site