3 ms·
Plain decorators work how you expect but generators are different. The decorator generator is called at import time, which is when the association between the r
by zrail 12y ago
Plain decorators work how you expect but generators are different. The decorator generator is called at import time, which is when the association between the route and the function is stored.
- catchmrbharath 12y agoHow is the decorator mentioned in the article a decorator generator? Edit:Sorry. I did not notice the term decorator generator in the article. Thanks for the explanation
- ekimekim 12y agoWell, no. The decorator generator is called first, then the decorator is called, all at the time when the line "@app.route()" is first reached during import. You could just as easily write @foo.bar[baz]('abc').hello and it would still work - the code after the @ is just an expression that should return a callable.