[Python-3000] PEP 3133: Introducing Roles

Guido van Rossum guido at python.org
Wed May 16 06:46:48 CEST 2007


On 5/14/07, Benji York <benji at benjiyork.com> wrote:
> Collin Winter wrote:
> > PEP: 3133
> > Title: Introducing Roles
>
> Everything included here is included in zope.interface.  See in-line
> comments below for the analogs.

Could you look at PEP 3119 and do a similar analysis? I expect that
the main thing missing there is that it (currently) has no way to
claim that a particular *object* has a certain behavior. The
overloading of isinstance() makes it possible to add this however --
if not as part of that PEP, then as part of a revamping of
zope.interface using isinterface()/issubclass() overloading and PEP
3129 style class decorators. PEP 3119 currently also doesn't have a
verification step -- but this could easily be added as an (optional)
part of the registration call.

If this is confirmed, I like the convergence that this suggests -- if
several designs (ABCs, Roles and zope.interface) mostly map onto each
other, we're probably on to an important concept, even if we can
quibble over the spelling of behavior checks and other details. It
also all appears to dovetail nicely with GFs.

BTW I think Collin made a mistake when he claimed that the Doglike
role should throw a tantrum just because the actual bark()
implementation has an optional extra argument; that would be like
complaining that it also has  a poop() method which is not part of the
Doglike role. :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list