[Python-Dev] Decorator syntax J2 (decorate..def), with implementation

Michael Sparks Michael.Sparks at rd.bbc.co.uk
Mon Aug 16 12:55:57 CEST 2004


Nick Coghlan> [make block optional for one decorator ?]
Barry Warsaw> [Better, but requires keyword, and hence (?) __future__ ]

Robert Brewer wrote:
> ...which Guido hasn't completely ruled out (unlike most of the other
> 'potential' alternatives):
> http://mail.python.org/pipermail/python-dev/2004-August/047001.html .

It was (partly) reading this post that made me think it worthwhile 
implementing this syntax. I actually prefer keyword inside the function 
block, but I know that's ruled out, and can see why. As a result for me this 
is my second choice. Sure, I can live with the @pie syntax, but *personally* 
I prefer having a keyword.

As previously noted the arguments against the length of the decorator in the 
single case, I view as advantages when showing code to new users or 
maintainers.

As for whether it's the right keyword or not, I'm not sure I'm qualified to 
say, but decorators seem much more like declarations of function properties 
in all the use cases I've seen.

> Personally, I feel decorators are powerful enough to warrant a more
> structured change process like __future__; it seemed to work quite well
> for generators. Perhaps any new feature which ends in "-rators" warrants
> it. ;)

As a circular use case, I realised that the generator implementation in 
test3.py from Armin Rigo's greenlets package would allow one to write:

decorate:
   generator
def some function(bla):
   for i in xrange(1):
      Yield(X)

So you *could* argue the case for "swapping" keywords... ;-) (not serious :)

More seriously though, if there is interest I'll see what I can do about 
cleaning up the patch to resolve the scoping issue.

Also I just realised that I didn't introduce myself (as per list 
instructions...). I don't know if this is still in vogue or not, but here 
goes...

I've been using python for 2 years now, and prior to that used perl/C/C++
for around 4 years as my main languages. I've worked on large scale 
network systems for most of my working life, but also worked on 3D 
graphics, and translation between a high level language to asynchronous
hardware (handshake circuits) code generator. I've also contributed to 
a variety of F/OSS projects (in different ways!) in the past including squid,
linux virtual servers, and Vorbis, largely because I think it's one of the
nicest way of saying "thank you" :)

I also like B5, Cordwainer Smith and I'm scared of spiders :)

Regards,


Michael.
-- 
Michael Sparks, Senior R&D Engineer, Digital Media Group
Michael.Sparks at rd.bbc.co.uk,
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This e-mail may contain personal views which are not the views of the BBC.


More information about the Python-Dev mailing list