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

Decorators are essential - Python Tutorial

From the course: Python for JavaScript Developers

Start my 1-month free trial

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…

Contents