[Python-3000] Traits/roles instead of ABCs (original) (raw)

Steven Bethard steven.bethard at gmail.com
Mon Apr 30 19:46:31 CEST 2007


On 4/30/07, Collin Winter <collinw at gmail.com> wrote:

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

I guess I don't understand why this bothers you more than how you can currently mess with class::

>>> class X(object):
...     __class__ = property(lambda self: Y)
...
>>> class Y(object):
...     pass
...
>>> isinstance(X(), Y)
True

The X class does not inherit from the Y class, yet it tells us that it does. To me, that certainly looks like "monkey[ing] with fundamental, bedrock properties of inheritance-based object orientation".

Maybe you could give a couple realistic examples of where you think people using isinstance and issubclass are going to break things unintentionally?

STeVe

I'm not in-sane. Indeed, I am so far out of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy



More information about the Python-3000 mailing list