[Python-ideas] [Python-Dev] Decorator syntax

Nick Coghlan ncoghlan at gmail.com
Wed Sep 2 13:18:57 CEST 2009

Xavier Morel wrote:
> On 2 Sep 2009, at 12:15 , Rob Cliffe wrote:
>> @Identity(DecoList[0])    # THIS WORKS
>> def foo():
>>    pass
> For what it's worth, you don't need an id function, you can simply write
>     @itemgetter(0)(decorators)
>     def foo():
>         'whatever'
> or
>     @decorators.__getitem__(0)
>     def foo():
>         'whatever'

To be honest, I'd forgotten the restriction was even there. So +0 on
removing it and relying on "consenting adults" and style guides to keep
people from getting to obscure with their decorators.

However, any such change should also be accompanied by an update to PEP
8 (recommending the current syntactic restrictions as style rules for
the standard library).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list