On Sun, 05 Jun 2011 19:15:02 +0100, Nobody wrote: > On Sun, 05 Jun 2011 07:21:10 +0000, Steven D'Aprano wrote: > >> Returning a sentinel meaning "an exceptional event occurred" is hardly >> unusual, even in Python. str.find() does is, as does re.search() and >> re.match(). > > These are not "exceptional" conditions; if they were, an exception would > be used.
Exceptional does not mean rare or unexpected. Searching for a substring returns the offset of that substring. If it is not found, that's the exceptional case. str.index raises an exception, and str.find returns a sentinel: >>> "spam".index("z") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: substring not found >>> "spam".find("z") -1 >>> As for IEEE-754 saying that it's [NAN == NAN] True: they only really >>> had two choices: either it's True or it's False. >> >> Incorrect. They could have specified that it was an error, like >> dividing by zero, but they didn't. > > Specifying an error doesn't remove the requirement to also specify a > result. Untrue, but irrelevant. (Standards often allow implementation-dependent behaviour.) The standard *could* have said that NAN == NAN be an error, but *didn't*, so what it should or shouldn't have done if it were an error is irrelevant, because it's not an error. And thus we come back full circle. Hundreds of words, and I'm still no closer to understanding why you think that "NAN == NAN" should be an error. -- Steven -- http://mail.python.org/mailman/listinfo/python-list