News for hackers. Stuff that matters.
Re:A primer on Python decorators by enaeseth on Wednesday April 11, 2012 @08:30PM (#3830351)
Here's the source of Flask's `route` decorator:

https://github.com/mitsuhiko/flask/blob/master/flask/app.py#...

When you call `route` with a URL pattern, it returns an inner function which is used as the decorator. That decorator just records your route and function in the Flask URL map, and returns your function unchanged.

So, Flask is arguably perpetuating a slight abuse of decorators, since it doesn't decorate or wrap your function at all, but merely saves a reference to it somewhere. But it's a fairly clean way to make up for the lack of code blocks or multi-statement anonymous functions in Python.

There are no comments on this comment yet.