Here is another problem in this general area. Multiplying an array by a
float already raises a type error.
>>> []*0.0
Traceback (most recent call last):
TypeError: can't multiply sequence by non-int of type 'float'
This problem can arrse 'by accident'. For example, consider
>>> x = {0.0}
>>> x.update(range(3))
>>> list(x)
[0.0, 1, 2]
Let's now return to the feature (of the builtin list, tuple and str
classes):
>>> [1] * (-1) == []
True
On the one hand I expect there's code that relies on the feature to run
correctly. On the other hand I expect there's code that should raise an
exception but doesn't, because of this feature.
@ericfahlgren
It would be most helpful if you could provide or create a reference to
support your claim, that there is already a lot of code that would fail if
this change was made.
@fjwillemsen
It would be most helpful if you could provide real-world examples of code
where raising an exception would enable better code.
Examples relating this are of course welcome from all, not just the two
named contributors.
--
Jonathan
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/6M6SRF6TGKR26BCCC2JIQEKFEFYLADZQ/
Code of Conduct: http://python.org/psf/codeofconduct/