On Mon, Mar 2, 2009 at 2:41 AM, Paul Moore <p.f.mo...@gmail.com> wrote: > ... > More generally, there is NO WAY to determine the list of classes for > which issubclass(C, x) is true. > > This could be considered a limitation of, or a bug in, ABCs, I don't > have a particular opinion on that, but it does mean that no code which > relies on being able to traverse the class inheritance graph will see > ABCs. One particular case of this is (any implementation I can think > of, of) generic functions. > > In my view, this implies one of the following: > > 1) It should be a documented limitation of such code that it doesn't > work with ABCs (and conversely, this limitation of ABCs should be > documented in the ABC documentation) > 2) Generic functions, and any other code requiring this type of > introspection, is essentially useless unless it can support ABCs, and > should not be used in the light of this limitation. > 3) This is a bug in ABCs and should be fixed. > 4) Something else I didn't think of :-)
I tend to think it's a bug in ABCs. You seem to have thought of several possible ways to fix it, and I don't have strong preferences between them. One way to deal with __subclasscheck__ definitions other than ABCMeta.__subclasscheck__ would be to make the "someone registered a subclass" interface public in addition to the "tell me when someone registers a subclass" interface. Then other __subclasscheck__ definitions could call the "someone registered a subclass" method when the class is defined if they want to be usable with generic functions. You can get something similar to the mro by checking whether ABCs are subclasses of each other. Jeffrey _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com