Guido van Rossum wrote: > **Open issues:** Conceivably, instead of using the ABCMeta metaclass, > these classes could override ``__instancecheck__`` and > ``__subclasscheck__`` to check for the presence of the applicable > special method; for example:: > > class Sized(metaclass=ABCMeta): > @abstractmethod > def __hash__(self): > return 0 > @classmethod > def __instancecheck__(cls, x): > return hasattr(x, "__len__") > @classmethod > def __subclasscheck__(cls, C): > return hasattr(C, "__bases__") and hasattr(C, "__len__") > > This has the advantage of not requiring explicit registration. > However, the semantics hard to get exactly right given the confusing > semantics of instance attributes vs. class attributes, and that a > class is an instance of its metaclass; the check for ``__bases__`` is > only an approximation of the desired semantics. **Strawman:** Let's > do it, but let's arrange it in such a way that the registration API > also works. > > > just to say that I still think the strawman would be right thing to do.
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com