At 11:07 AM 3/29/2006 -0800, Guido van Rossum wrote: >On 3/28/06, Phillip J. Eby <pje at telecommunity.com> 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.)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4