[Python-ideas] Multiple arguments for decorators

Andrew Barnert abarnert at yahoo.com
Tue Dec 1 21:05:49 EST 2015


On Dec 1, 2015, at 15:22, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 
> Suppose you were able to write:
> 
>   @somedecorator as name:
>      <suite>
> 
> and have it be equivalent to
> 
>   @somedecorator:
>      class name:
>         <suite>

Do you mean equivalent to this?

    @somedecorator
    class name:
        <suite>

If so: what's the problem with what we already have? There's no double indenting going on, or anything else ugly or obtrusive, when spelled properly. And I don't see why making it easier to write a class where it's harder for the reader to tell you've done so is an aid to readability. Also, it means the "foo" is no longer in the usual place (def /class statement or assignment), so now we have to all learn to scan three different places where attributes can get named instead of just two, and the new one (unlike the existing two) only appears in classes, not at module or local scope.


More information about the Python-ideas mailing list