At 08:45 PM 2/19/04 +0100, Thomas Heller wrote: >But there is not really a dramatical advantage over this notation, with >a suitable metaclass: > >class Foo(object): > __metaclass__ = SomeMetaclass > __provides__ = [IFoo] Actually, there *is* a dramatic advantage over that notation, since the idea is to allow the object to retain its *own* metaclass, not force it to use a different one. The "magic" syntax used by Zope and PyProtocols leaves the original class definition's metaclass completely unchanged, and the class decorator syntax could do the same. I'm not really strongly arguing for class decorator syntax, though, because the "magic" approach works well enough for me. I'm just pointing out that there *is* a reasonable use case for it. (Also, the "magic" approach has an additional disadvantage, in that if someone explicitly sets __metaclass__ *after* a magic function, it will silently prevent the magic from occurring. The class decorator syntax wouldn't have this problem.) While we're on the subject of PEP 318, I'd also like to mention that I find the: def foo() as bar: ... syntax much more readable than the: def foo() [bar]: ... syntax. But I'll take whatever I can get. :)
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