[Python-Dev] PEP 318 - posting draft
Bob Ippolito
bob at redivi.com
Wed Mar 24 11:55:54 EST 2004
On Mar 24, 2004, at 10:59 AM, Skip Montanaro wrote:
> Bob> For example, ZopeX3 interfaces and PyProtocols interfaces
> both use
> Bob> sys._getframe() introspection to add a temporary metaclass so
> that
> Bob> they can ...
>
> Guido> But the use cases are certainly very *different* than those
> for
> Guido> function/method decorators, and should be spelled out
> separately.
>
> Guido> For example, I'd like to see you show in much more detail
> how
> Guido> class decorators could be used to replace those Zope3 hacks.
>
> Bob, if you can come up with an example or two that won't consume
> infinite
> space, I'd be happy to add it/them to the Examples section of the PEP.
def provides(*interfaces):
"""
An actual, working, implementation of provides for
the current implementation of PyProtocols. Not
particularly important for the PEP text.
"""
def provides(typ):
declareImplementation(typ, instancesProvide=interfaces)
return typ
return provides
class IBar(Interface):
"""Declare something about IBar here"""
class Foo(object) [provides(IBar)]:
"""Implement something here..."""
No stack introspection, no forced superclass or metaclasses, no
side-effects on subclasses, etc. Foo is entirely unchanged by this
operation (in PyProtocols at least).
-bob
More information about the Python-Dev
mailing list