Alternative decorator syntax decision

Christophe Cavalaria chris.cavalaria at free.fr
Fri Aug 20 20:32:45 EDT 2004


Paul Morrow wrote:

> Note: This is *not* about implicit method typing... :-)
> 
> Although I haven't seen it discussed anywhere, we already have a
> decorator syntax (of sorts) that we use to annotate functions and
> classes.  The " __var__ = " business.  Have we decided that it is
> woefully insufficient?  I know that there is a preference for the
> decorators to appear outside of the function def, but putting that
> aside, this 'style' of decorating already has a precendent in python, so
> it is probably as pythonic as you can get...
> 
>      class Foo:
>          __metaclass__ = M
>          __automethods__ = True
>          __author__ = 'Paul Morrow'
>          __version__ = '0.1'
> 
>      def baz(a,b,c):
>          __synchronized__ = True
>          __accepts__ = (int,int,int)
>          __returns__ = int
>          __author__ = 'Fred Flintstone'
> 
> return a + b + c
> 
> 
> What is the burning desire to abandon this style?
> 
> Paul

By what kind of black magic would setting the property __synchronized__ to
True would make that function synchronized ? And how can I define my own
decorators then ? And what about the other usage patterns for decorators
like the easy property getter/setter definition ?



More information about the Python-list mailing list