tweaking @decorator syntax
Hallvard B Furuseth
h.b.furuseth at usit.uio.no
Fri Aug 6 05:53:29 EDT 2004
Andrew Durdin wrote:
> it is
> not at all obvious to me that it is rather a kind of attribute or
> modifier of the following function definition. I don't know of any
> other construction in Python that performs a similar, unmarked (i.e.
> non-explicit) modification of the following statement.
Right. Today, both the human and the compiler can parse that kind of
thing just by looking at the indentation.
Still, if we do get a new way to indicate that something is parsed
differently, then a special character like @ would be good for that.
'@some-directive' in general could be a statement which the compiler
reacts to in some way, and decorators could be a special case:
@decorator <decorator_name>
instead of just
@<decorator_name>
That gives the human reader a keyword he can relate to instead of a
special character with an obscure meaning, and the @ character tells
him that there is something special about this statement.
Though in the case of decorators, I still prefer several of the other
suggestions over this one.
--
Hallvard
More information about the Python-list
mailing list