[Python-Dev] Another approach to decorators. (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Wed Aug 11 22:11:37 CEST 2004


Martin Zarate wrote:

@ means nothing to an uninformed eye. This violates the most important feature of Python (imho) which is that it is "runnable pseudocode". A coder will see what "def" or "class" or "import" means just by looking at it. @ is meaningless.

I think it is irrelevant that @ means nothing in this context. Python will still be runnable pseudo-code. Remember that the decorator will read

@staticmethod

So the eye unfamiliar with Python may wonder what the @ means. As you suggest, it means nothing, and the reader will see the staticmethod after it, and guess (correctly): "this somehow make a static method".

I submit that a reserved keyword would fit much better in the @ place.

To the uninformed eye, this would be harmful. It may have a grasp what a static method is, and that you have to declare it. However, what does the additional keyword mean? The uninformed eye will try to put a meaning into it, but there is none. The unformed eye will never guess how static methods work in Python - that the method is actually an object, that "staticmethod" is actually a type, and this all is a constructor call, assigning to the name of the function.

I'm sure you can all think of something better than @.

Actually, I can't. Your post just convinced me that a keyword can never be better.

Regards, Martin



More information about the Python-Dev mailing list