[Python-Dev] A usability argument for list-after-def

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Fri Aug 6 00:58:53 CEST 2004


Aahz wrote:

> I've been staying out of this because I thought my preference had no
> chance to make it in (i.e. I don't care between "no decorators" and "@
> decorators"), but if it's getting some revival, I want to make clear
> that I think putting decorators *after* ``def``, name, and parameter
> list but clearly *with* the function definition makes the most sense
> for readability -- in the simple cases.  Who cares about the complex
> cases, because it's always going to be ugly?

+1

This has been my position all along. I understand the need for decorator
syntax (and even defended pie-syntax on c.l.py for that reason) but I
think that of all the alternatives, list after parameters, before colon
is the best alternative presented.

    def func (params) [decorators]:
        pass

To me this conveys the information I need clearly and in the order that
I need it - name is most important, parameters second, and the "type" of
function last.

The vast majority of functions are between 1 and 3 parameters.
Similarly, I doubt there will be many functions with more than a couple
of decorators.

Having everything on a single line in the majority of cases is IMO a big
win - both for readability and understandability.

Tim Delaney


More information about the Python-Dev mailing list