Section 2 Review
This video concludes Section 2 on Decorators. You now know how to:
- Create simple decorators and apply them to functions
- Apply syntactic sugar by using the
@
symbol to decorate your functions - Reuse decorators and import them in your programs
- Decorate functions with arguments
- Return values from decorated functions
- Perform introspection on Python objects and how to use
functools
In the next section, you’ll cover a few real world examples.
Free Bonus: Click here to get access to a free "The Power of Python Decorators" guide that shows you three advanced decorator patterns and techniques you can use to write cleaner and more Pythonic programs.
Decorators Cheat Sheet: Click here to get access to a free three-page Python decorators cheat sheet that summarizes the techniques explained in this tutorial.
00:00 Congratulations on finishing Section 2! By using the information that you learned in Section 1, you are ready to start using decorators. I showed you some simple decorators and how to apply them to your functions.
00:15
Next up, you learned how to apply a little bit of syntactic sugar by using the at symbol (@
) to decorate your functions as you define them, or even after you define them. After that, it was all about reusing decorators on multiple functions. Here, you saved your decorators in a module that could be imported and used at any time.
00:37
And then you covered what you need to be aware of when you’re decorating functions that have arguments. And I discussed with you *args
and **kwargs
—positional arguments and keyword arguments. Next, now that you’ve passed information into a function, you covered how to return values from your decorated functions.
01:02 And last, you talked about introspection,
01:07
and “Who are these functions, really?” and how to use functools
. Great! Now you’re ready to look at a few real-world examples in Section 3.
Become a Member to join the conversation.
teodorwisniewski on Oct. 20, 2019
Great course! Thank you Mr. Chris. I really like the way you explain stuff!