DEV Community

Discussion on: What Are Python Decorators Anyway?

Collapse
 
mburszley profile image
Maximilian Burszley • Edited

A one-liner:

They're functions that wrap functions to provide additional functionality.

In your opener with Flask, what its route function does is register the views with the framework so you're not doing something like:

import flask

def index() -> flask.Flask:
    return flask.make_response('', 200)

app = flask.Flask('app')
app.add_url_rule('/', 'index', index)

It makes the framework a little more declarative.