[Python-Dev] PEP 318 - posting draft
Bob Ippolito
bob at redivi.com
Wed Mar 24 10:00:53 EST 2004
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
More information about the Python-Dev
mailing list