re: What Are Python Decorators Anyway? VIEW POST


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.

code of conduct - report abuse