[Python-Dev] Re: Call for defense of @decorators

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Fri Aug 6 01:48:29 CEST 2004


Shalabh Chaturvedi wrote:

>     |paramnames(username='Username', password='Password')
>     |webmethod(username=str, password=str)
>     def login(self, username, password, return_to=None):
>         request = current.request
>         ...
> 
>     |webmethod()
>     def logout(self, return_to=None):
>         current.request.session.user = None
>         return current.request.redirect(return_to or self._q_location)
> 
> Appears accentuated, yet clean, specially for simple/single
> decorators. 
> Gives an appearance that the decorators are 'connected' to the
> function. 

This looks remarkably nice to me for a syntax before the definition.
Astoundingly so. I still prefer list-before-colon, but the above would
alleviate much of my distate for @ which is that it doesn't look as
though the decorators are connected to the definition.

Hmm - perhaps a further variation ...

    |paramnames(username='Username', password='Password')
    |
    |webmethod(username=str, password=str)
    |
    def login(self, username, password, return_to=None):
        request = current.request

i.e. the decorators must be connected to the def, but you can use some
whitespace to make them look better (for decorators with long parameter
lists). Would be hell to parse though ...

Tim Delaney


More information about the Python-Dev mailing list