[Python-Dev] Another approach to decorators.

Brett C. bac at OCF.Berkeley.EDU
Thu Aug 12 03:36:27 CEST 2004


Michel Pelletier wrote:
> On Wed, 11 Aug 2004 14:03:11 -0700
> "Brett C." <bac at ocf.berkeley.edu> wrote:
> 
> I said:
> 
>>>class Foo:
>>>
>>>  decorate static:
>>>
>>>    def static1(blah...):
>>>        pass
>>>
>>>    def static2(blah...):
>>>        pass
>>>
>>>To me, this idea looks more like Python than all the rest, and allows
>>>you to consolidate related decorated methods and classes.  Nest them to
>>>apply decorators "aquisition style":
>>
>>But then how are you supposed to do multiple decorators for the same method?
> 
> 
> Put more than one of them in the same decorate block:
> 
> class ...
> 
>   decorate staticmethod, locksFile(arg1):
> 
>     def meth1(...)
>       ...
> 
>     def meth2(...)
>       ...
> 
> 

I still don't like it.  It feels like I am classifying my methods based 
on the applied decorators instead of thinking of decorators as, well, 
decorators of methods.  I feel methods are the major thing and 
decorators are just extra fluff on them, not the other way around as 
this syntax says to me.  Changing the indentation delineates scope and I 
don't feel decorators truly represent a change in scope.

>>I am with Martin that a keyword argument is not going to work here. 
> 
> 
> I presume you mean MvL and not the orginal poster, Martin Zarate.
> 

Yep, sorry for not being clearer.

> 
>>Going that route leads to ``public static 
>>painInTheAssAndClutteredSyntax(That can) implements Lots, Of, Stuff, 
>>That throws Things, You, Can, Learn, From, The, Docs`` hell.
> 
> 
> How does Martin Z's idea lead to this?
> 

A keyword followed by a comma-separated list of what that keyword affects.

-Brett


More information about the Python-Dev mailing list