From the course: Python for JavaScript Developers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Decorators are essential - Python Tutorial
From the course: Python for JavaScript Developers
Decorators are essential
- [Instructor] If you use Python for web development, at some point you're likely to encounter a micro framework called Flask. Now, if we head over to Flask's documentation at flask.palletsprojects.com, there is a really nice example of a five line web application. And if you look at it, the first two lines are importing Flask and then creating an app instance. But then you'll see the @ sign followed by app.route and then a really basic function called hello_world. Now, hello_world is a really simple function. It basically returned as the string hello world but it seems like something is happening behind the scenes here. Something that is taking hello world and turning it into a web application route. Now app.route is a decorator and while decorators do exist in JavaScript, they're much more prominent in Python. So it's worth taking a moment to demystify decorators a bit in order to make you more comfortable using…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Iterating in Python3m 46s
-
(Locked)
Writing concise code with zip and enumerate3m 39s
-
(Locked)
From JavaScript map and filter to an elegant Python comprehensions6m 2s
-
(Locked)
Decorators are essential3m 35s
-
(Locked)
Challenge: Map to comprehension5m 19s
-
(Locked)
Solution: Map to comprehension2m 32s
-
(Locked)
-