This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Ramchandra Apte, franck, mark.dickinson, terry.reedy
Date 2013-02-09.02:59:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1360378764.82.0.729302107401.issue17157@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-02-09 02:59:24terry.reedysetrecipients: + terry.reedy, mark.dickinson, Ramchandra Apte, franck
2013-02-09 02:59:24terry.reedysetmessageid: <1360378764.82.0.729302107401.issue17157@psf.upfronthosting.co.za>
2013-02-09 02:59:24terry.reedylinkissue17157 messages
2013-02-09 02:59:24terry.reedycreate