[Python-Dev] 2.4a2, and @decorators (original) (raw)
Barry Warsaw barry at python.org
Tue Aug 3 20:01:42 CEST 2004
- Previous message: [Python-Dev] 2.4a2, and @decorators
- Next message: [Python-Dev] 2.4a2, and @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 2004-08-02 at 23:51, Guido van Rossum wrote:
And yes, I'm not 100% comfortable with it either. But I know one thing: in this particular case, now is better than never. So I'm picking a solution everybody can hate equally.
(What's wrong with pear-shaped, anyway? It's one of my favorite shapes. :-)
So I conducted a little experiment, converting a bunch of modules that were using Python 2.3 compatible "post-processing" decorator syntax, to pie decorator syntax, so that I could get a more visceral reaction to the decision. For me, the short answer is: +1, and not just because "it's better than nothing".
For longer functions, it's a clear win; the '@' stands out nicely, especially with the python-mode.el font-locking support I just added. :) It certainly exhibits all the benefits that motivated adding special syntax for decorators in the first place.
For shorter functions, e.g. read-only accessors, my only (very minor) lament is that I can't compact the enter thing down to a single line. My fingers want to do something like:
@property def get_bacon(self): return self._bacon
but then I tell my fingers to do this instead:
@property
def get_bacon(self):
return self._bacon
Or, we'll compromise, my fingers and I, on:
get_bacon = property(lambda self: self._bacon)
So it's at least a wash there. (Really, pie decorators are better here too, IMO.)
My only other minor lament has nothing to do with this specific syntax. I still wish there was a way to decorate multi-arg property()'s, but oh well.
All in all, I'm quite happy with this syntax. Thanks Guido! -Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20040803/d88a456e/attachment.pgp
- Previous message: [Python-Dev] 2.4a2, and @decorators
- Next message: [Python-Dev] 2.4a2, and @decorators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]