The winner of the Python Decorator Poll is...

Peter Hansen peter at engcorp.com
Thu Aug 12 00:28:18 EDT 2004


Doug Holton wrote:

> Which decorator syntax do you like the most? See 
> http://wiki.wxpython.org/index.cgi/PythonDecoratorsPoll
> A. @classmethod def foo(): (82)     14%    
> C1. def foo() [classmethod]: (235)     41%    
> E1. def foo(): @classmethod (260)     45%    
> 
> Total Votes: 577
> 
> People are about 6 to 1 against having the decorators come before the 
> "def" keyword.

While I voted in that poll, and in fact voted for one of the
two "after" methods (I forget which, doesn't matter), I want
to point out the danger of extrapolating from the poll results
to unsubstantiated claims such as the one you make.

The poll results show that by a ratio of 6 to 1, people
who voted prefer either of the second two options to the
first one.  Nothing more, nothing less.  The poll didn't
mention that it was a choice between before and after,
and therefore you shouldn't make assumptions about what
was in the minds of those voting.

For example, had the "decorate:" option that recently evolved
from discussion in this forum been present, I would have
preferred it over any of the methods show above.  That's
because I'm not religious about the before or after thing
so much as I am over the punctuation and Pythonic-style
issues.  The "decorate:" option is the closest fit with
Python style, IMHO, even more so than list-after-def, and
even the fact that it comes before the def doesn't bother
me since the indented block structure feels very similar
to other such constructs in Python.

And I'm sure I'm not alone, but nobody's done a poll on
it yet. ;-)

-Peter



More information about the Python-list mailing list