In this tutorial, I explain decorators in a very simple way by going over how to measure execution time of function using decorators. They serve as a wrapper to original function but does a wonderful job of avoiding code duplication and not cluttering original code with additional logic.
Exercise: https://github.com/codebasics/py/blob/master/Basics/Exercise/25_decorators/25_decorators.md
Do you want to learn technology from me? Check https://codebasics.io/ for my affordable video courses.
Code in this tutorial is available here: https://github.com/codebasics/py/blob/master/Advanced/decorators.py
Website: http://codebasics.io/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub
Continue this lesson in the app
Install CourseHive on Android or iOS to keep learning while you move.