#100DaysOfCode in Python Transcripts
Chapter: Days 22-24: Decorators
Lecture: Examples of real life decorators

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, that concludes the basic coverage
0:02 of decorators in Python.
0:04 In this section I provide you some more pointers
0:06 to study some more decorators today.
0:10 I did an article on Twilio,
0:12 and in this app I used a login required decorator
0:15 to check if the user is logged in.
0:18 And you can see that in the code.
0:21 This is what you already saw in this lesson.
0:24 The wraps, and the wrapper.
0:26 It takes the arguments and just checks
0:28 if login is in the session.
0:30 If so, return to function.
0:32 If not, do a flash message and redirect to the login page.
0:37 That's similar to what Django is doing,
0:40 which, I pointed to the source.
0:41 You can check that out as well.
0:43 There's some more stuff going on
0:44 so I challenge you to take a look at this code
0:47 if you have time left today.
0:49 And on PyBites we did an article,
0:52 "Learning Python Decorators By Example,"
0:55 which partly overlaps with
0:56 what you have seen in the lesson so far,
0:58 but there are also some more examples for caching,
1:01 some more decorators in the wild.
1:04 And I point you to another article.
1:07 Sometimes you need a decorator that takes arguments
1:10 like speed decorator that takes seconds
1:13 and it's not always straightforward
1:14 how optional arguments work
1:16 so I wrote an article about that.
1:17 So if you still have time left today
1:19 and you want to know decorators a bit more in detail
1:22 you can read this article as well.
1:26 And that concludes the lesson of Day 1.