Re: Python decorator syntax limitations

2010-01-18 Thread Jonathan S
Thanks a lot, all of you! This was really helpful. (or at least give me the inspiration I needed to finish it.) I'm sure this is a use case where most other options are less readable than the chain of methods in the decorator. In this use case, I had a lot of Django views to which access permissio

Re: Python decorator syntax limitations

2010-01-18 Thread Arnaud Delobelle
a...@pythoncraft.com (Aahz) writes: > In article <4b54998...@dnews.tpgi.com.au>, > Lie Ryan wrote: >> >>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

Re: Python decorator syntax limitations

2010-01-18 Thread Aahz
In article <4b54998...@dnews.tpgi.com.au>, Lie Ryan wrote: > >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 discus

Re: Python decorator syntax limitations

2010-01-18 Thread Peter Otten
Jonathan S wrote: > Hi all, > The following is what I want to do, but this results in a syntax > error: > > > @news_page('template.html').lookup(News, 'news_id', 'news') > def view(request, group, news): > pass > > > What does work is the equivalent old way of doing decorating: > > > def

Re: Python decorator syntax limitations

2010-01-18 Thread Lie Ryan
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

Re: Python decorator syntax limitations

2010-01-18 Thread Steve Howell
On Jan 18, 8:44 am, Jonathan S wrote: > Hi all, > The following is what I want to do, but this results in a syntax > error: > > @news_page('template.html').lookup(News, 'news_id', 'news') > def view(request, group, news): >     pass > > What does work is the equivalent old way of doing decorating:

Python decorator syntax limitations

2010-01-18 Thread Jonathan S
Hi all, The following is what I want to do, but this results in a syntax error: @news_page('template.html').lookup(News, 'news_id', 'news') def view(request, group, news): pass What does work is the equivalent old way of doing decorating: def view(request, group, news): pass view = ne