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 veky
Recipients eric.smith, mrabarnett, pablogsal, rhettinger, serhiy.storchaka, terry.reedy, veky, xtreak
Date 2021-03-20.05:31:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616218299.83.0.765773601988.issue43535@roundup.psfhosted.org>
In-reply-to
Content
Matthew: can you then answer the same question I asked Serhiy?

The example usually given when advocating strong typing is whether 2 + '3' should be '23' or 5. Our uneasiness with it doesn't stem from coercions between int and str, but from the fact that + has two distinct meanings.

Of course, binary operators are always like that, even if it's not obvious, since there's always a tension created by difference of types of the left and right operand. Even if it's obvious that 2 - '3' should coerce the second argument to int since str doesn't define -, this can't be a general rule because e.g. set does (what about 2 - {3}?).

But method calls (and many protocols) are _not_ of that kind. As I said above, my_set ^ some_list makes us uneasy (even though list doesn't implement ^), but my_set.symmetric_difference(some_list) doesn't, simply because there is no ambiguity: there is only one thing we could have meant.

The same can be said about "for x in not_an_iterator", or "if not_a_bool".
History
Date User Action Args
2021-03-20 05:31:39vekysetrecipients: + veky, rhettinger, terry.reedy, eric.smith, mrabarnett, serhiy.storchaka, pablogsal, xtreak
2021-03-20 05:31:39vekysetmessageid: <1616218299.83.0.765773601988.issue43535@roundup.psfhosted.org>
2021-03-20 05:31:39vekylinkissue43535 messages
2021-03-20 05:31:38vekycreate