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
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