[Python-Dev] Re: Questions about '@' in pep 318

David Eppstein eppstein at ics.uci.edu
Fri Aug 6 00:22:54 CEST 2004


In article <003601c47b34$0b4bf660$6700a8c0 at computer>,
 "Edward K. Ream" <edreamleo at charter.net> wrote:

> I hope I am not being incredibly stupid, but I am thinking only of syntax
> here.  So wherever the community would have decided to put:
> 
> @accepts <<whatever>>
> 
> the new "syntax" would be:
> 
> annotate.accepts <<whatever>>
> 
> Do you see? The annotate "module" probably doesn't exist at all.  I think of
> it as a pseudo-module.  That's why I wrote "from __future__ import
> annotation as annotate" in the original post.
> 
> My thinking is this:  apparently people like the @ syntax.  Why not do some
> magic and compile module references to the annotation pseudo-module just as
> it is presently proposed to compile the @ syntax.

I'm not convinced this is possible in general (for all pythons, 
obviously it's possible by gross hacks in CPython) without making 
annotate into a keyword.

And, I don't like the choice of the word, either, since I think 
decorators are more likely to be used to change the meaning of the 
definition and not just attach some meaningless annotation to it.

Anyway, since decorators are quite different from normal control flow in 
Python I'd prefer to see them given a syntax that stands out, that makes 
it obvious that it's not just some slightly mysterious function call 
prior to the def.  @syntax does that for me and yours doesn't.

-- 
David Eppstein
Computer Science Dept., Univ. of California, Irvine
http://www.ics.uci.edu/~eppstein/



More information about the Python-Dev mailing list