At 11:07 AM 3/29/2006 -0800, Guido van Rossum wrote: >On 3/28/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > > If we're using Zope 3 as an example, I personally find that: > > > > class Foo: > > """Docstring here, blah blah blah > > """ > > implements(IFoo) > > > > is easier to read than: > > > > @implements(IFoo) > > class Foo: > > """Docstring here, blah blah blah > > """ > >But the former also smells more of magic.
My comment above was only about readable *placement* of the decorators, not the actual syntax. Many approaches to the actual syntax in the body are possible. For example, what did you think of Fred Drakes's "@class" proposal? To specify it formally, one could say that this: @class EXPR in a class scope would expand to the equivalent of: locals().setdefault('__decorators__',[]).append(EXPR) and is a syntax error if placed anywhere else. That, combined with support for processing __decorators__ at class creation time, would fulfill the desired semantics without any implicit "magic". (The locals() part could of course be implemented in bytecode as LOAD_LOCALS, since class scopes implement their locals as a dictionary. That would avoid the need for adding any new bytecodes, since this isn't a performance-sensitive feature.) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com