Re: Decorator Syntax

2011-03-22 Thread Rafe Kettler
and it doesn't seem as closely tied syntactically. Of course, that's all opinion. But what's done is done; it's doubtful that the decorator syntax will ever change significantly. Rafe -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Syntax

2011-03-22 Thread Laurent Claessens
And I'm willing to bet that there are plenty of scripts out there that use "dec" as a name for Decimal objects. You won. I owe you a beer ;) Laurent -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator Syntax

2011-03-21 Thread Ian Kelly
On Mon, Mar 21, 2011 at 7:31 PM, Benjamin Kaplan wrote: > On Mon, Mar 21, 2011 at 8:59 PM, Mike Patterson > wrote: >> In my Python class the other day, the professor was going over >> decorators and he briefly mentioned that there had been this huge >> debate about the syntax and using the @ sign

Re: Decorator Syntax

2011-03-21 Thread Benjamin Kaplan
On Mon, Mar 21, 2011 at 8:59 PM, Mike Patterson wrote: > In my Python class the other day, the professor was going over > decorators and he briefly mentioned that there had been this huge > debate about the syntax and using the @ sign to signify decorators. > > I read about the alternative forms p

Decorator Syntax

2011-03-21 Thread Mike Patterson
In my Python class the other day, the professor was going over decorators and he briefly mentioned that there had been this huge debate about the syntax and using the @ sign to signify decorators. I read about the alternative forms proposed here (http:// www.python.org/dev/peps/pep-0318/#syntax-al

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
e 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 @

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

Re: Decorator Syntax For Recursive Properties

2005-04-17 Thread Jeffrey Froman
Peter Otten wrote: >> something like this didn't work for me: > But this will, I suppose: > > @property > def ancestors(self): > if self.parent: > return self.parent.ancestors + [self.parent] > return [] > > A non-recursive variant: > > @property > def ancestors(self): > r

Re: Decorator Syntax For Recursive Properties

2005-04-17 Thread Peter Otten
Jeffrey Froman wrote: > it is the originating node (the node trying to find its ancestors). So > something like this didn't work for me: > > @property > def ancestors(self): > if self.parent is None: > return [self.name] > return [self.name] + self.parent.ancestors But this will,

Decorator Syntax For Recursive Properties

2005-04-16 Thread Jeffrey Froman
parent property, rather than calling the property directly. Is it possible to rewrite this property using decorator syntax? Does the @property decorator create some underlying method that I can call directly? Alternately, perhaps there is a way to rewrite the recursion so that such a call is

Re: decorator syntax polling suggestion

2005-04-01 Thread D H
Jeremy Bowers wrote: On Fri, 01 Apr 2005 16:52:52 -0500, Jeremy Bowers wrote: Oops, sorry, some "send later" messages I thought were gone got sent. Sorry. Didn't mean to revive dead threads. At least it happened on April Fool's. Or should I say: @aprilfools def happened: at least -- http://mail

Re: decorator syntax polling suggestion

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 16:52:52 -0500, Jeremy Bowers wrote: Oops, sorry, some "send later" messages I thought were gone got sent. Sorry. Didn't mean to revive dead threads. -- http://mail.python.org/mailman/listinfo/python-list

Re: decorator syntax polling suggestion

2005-04-01 Thread Jeremy Bowers
On Fri, 13 Aug 2004 16:49:53 +1000, Anthony Baxter wrote: > The > people who hate pie-decorators post a _lot_ - most people seem to either > not care, or else post once or twice and then disappear. I just posted on another mailing list about how posting the same message, over and over, is fundamen