Terry J. Reedy added the comment: Given isxxx(src, target_s), the proposal would seem to be to change the internal test "type(target_s) is tuple" to "hasattr(type(target_s), '__iter__'). This depends on metaclasses not having .__iter__ methods, just as type does not. However, a subclass of type that added .__iter__, for instance to iterate through all its instances (classes defined with that metaclass), would break that test. So the proposal needs a better test, that cannot become ambiguous, to be practical.
A virtue of the 'class or tuple of classes' interface is that a tuple instance is clearly not a class in itself, so there is no possible ambiguity. It is a positive feature that isinstance and issubclass have the same signature: both or neither should be changed. The use of tuple for multiple items in 'item or items' interfaces is historical and also used elsewhere, as in exception clauses. The meaning of except target_exception_s [as name]: body is if issubclass(raised_exception, target_exception_s) or isinstance(raised_exception, target_exception_s): [name = raised_exception] body So to remain consistent, I think changing exception statements to allow iterables of exceptions should also be part of the proposal. There might be something else that I am forgetting about at the moment. While iterables might be used if Python were being written fresh today and the ambiguity problem were solved, I agree that more than esthetic satisfaction is needed to make a change. ---------- nosy: +terry.reedy _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17157> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com