[Python-3000] Traits/roles instead of ABCs

Collin Winter collinw at gmail.com
Mon Apr 30 18:50:09 CEST 2007


On 4/30/07, Bill Janssen <janssen at parc.com> wrote:
> > [Collin Winter]
> > +100 I'm very interested in seeing a lighter weight alternative to abc.py that:
> >
> > 1) is dynamic
>
> There's no reason ABC's can't be dynamic.
>
> > 2) doesn't require inheritance to work
> > 3) doesn't require mucking with isinstance or other existing mechansims
>
> Using existing mechanisms that work for the issue is always preferable
> to adding new ones that *also* work for the issue.

No existing mechanism would allow PEP 3141 to be distributed as a
third-party module and still impact the built-in types; that's what
this whole business of __isinstance__ and __issubclass__ is about. In
order to achieve dynamic composition, we're having to monkey with
fundamental, bedrock properties of inheritance-based object
orientation. The definition of "subclass" and "instance" is no longer
objective; the answer to "is X an instance of Y?" becomes, "I dunno,
ask Y".

Collin Winter


More information about the Python-3000 mailing list