[issue17157] issubclass() should accept iterables in 2nd arg

2020-11-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

except ... is another instance of (exception) class or tuple of classes.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2020-11-16 Thread Irit Katriel


Irit Katriel  added the comment:

Good discussion. There seems to be agreement that this should not be done.

--
nosy: +iritkatriel
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-09 Thread Franck Michea

Franck Michea added the comment:

I am neutral on this too, it just felt odd and this is why the question raised.

Yesterday I tried to add sequences and iterables (only to issubclass but indeed 
it would need better testing and all) and came to a problem with sequences. The 
current implementation authorizes (A, (B, (C, D))) (why?) so issubclass is 
recursive, but if we add sequences, they could create infinite recursions if 
seq[0] == seq (it's the case for strings for example, where 'a' is still a 
sequence and 'a'[0] == 'a').

So I don't know if it's really interesting. Anyone can use tuple() on an 
iterable to build its tuple value, though the value is built in memory. It 
basically just felt odd to take only tuples but I don't know.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-09 Thread Ramchandra Apte

Ramchandra Apte added the comment:

Just so you know, I'm neutral on this idea. I think it should at least accept 
sequences though.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Terry J. Reedy

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Mark Dickinson

Mark Dickinson added the comment:

What's the use case for this?  issubclass already accept tuples, just like 
isinstance:

>>> issubclass(bool, (int, float))
True

--
nosy: +mark.dickinson
versions:  -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte :


--
status: languishing -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte :


--
status: open -> languishing

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte :


--
title: issubclass should accept iterables -> issubclass() should accept 
iterables in 2nd arg

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

New submission from Ramchandra Apte:

kushou pointed this out on #python-dev

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte :


--
components: +Interpreter Core

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte :


--
nosy: kushou, ramchandra.apte
priority: normal
severity: normal
status: open
title: issubclass should accept iterables
type: enhancement
versions: Python 3.3, Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com