On 01/19/10 03:44, Jonathan S wrote: > Any suggestions? I have my reasons for doing this, (news_page is a > class, and __call__ is used to wrap the template.) > I'm sure this is a limitation in the syntax, but would parenthesis > somewhere help?
The restriction[1] is put in there since Guido has a "gut feeling" that allowing arbitrary expression in decorator syntax severely harms readability. http://mail.python.org/pipermail/python-dev/2004-August/046711.html A workaround is to put an assignment above it: nplookup = news_page('template.html').lookup @nplookup(News, 'news_id', 'news') def view(request, group, news): pass If you are sure you can put up a convincing argument for lifting this restriction, and you are willing to put some time arguing, you are welcome to start a thread in the python-dev mailing list. Be sure to read about previous discussions, as repeating arguments wouldn't change anything. [1] there is a subtle difference between "restriction" and "limitation" -- http://mail.python.org/mailman/listinfo/python-list