On Mar 24, 2004, at 9:28 AM, Guido van Rossum wrote: >> Actually, it should be deleted and the PEP updated. Michael's latest >> patch >> apparently supports class decorators, so it's no longer an extension. > > But while you're at it, please add to the PEP that I don't like the > idea of class decorators. I think they don't solve a real problem, > unlike function decorators, and I think that making classes and > functions more similar just adds confusion. I disagree. There's definitely a use case for something less permanent than a metaclass that gets a reference to a class immediately after creation but before it ends up in the module namespace. For example, ZopeX3 interfaces and PyProtocols interfaces both use sys._getframe() introspection to add a temporary metaclass so that they can declare that a class supports (or does not support) a particular set of interfaces from the class body itself. Using the [] syntax to decorate the class would deprecate these sorts of nasty hacks. -bob
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