[Python-Dev] Questions about '@' in pep 318 (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Fri Aug 6 20:38:16 CEST 2004


Edward K. Ream wrote:

I agree. The argument that @ lines aren't clearly "attached" to functions seems much more convincing to me.

I can't see that. In Python, things at the same indentation level all belong together. Would you say that in

try: foo() more_code() except expr: bar()

the except is not attached to the try? You probably wouldn't, because you know they belong together. However, you equally have no problem seeing how

while: foo() more_code() if expr: bar()

the while and the if don't belong together. People can learn these things, and learning the @ thing seems very easy.

2. Maybe the @ syntax is somehow the best alternative, considered in isolation. Fair enough. But how much better? Enough to justify a major change to the language? What is so unreadable about def (...)[...]: ?

That parameters and decorators are essentially in a single sequence, just separated by )[. It is important that you can easily tell how many parameters a function has, and how it is decorated.

Furthermore, this syntax will break more tools than the @decorator syntax.

In short, a major change to Python (@) would seem to demand a truly convincing justification. IMO, the argument that @ is more readable than def (...)[...]: doesn't even come close to such a justification.

Take into account also breakage of existing tools.

Regards, Martin



More information about the Python-Dev mailing list