Can global variable be passed into Python function?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun Mar 2 03:35:23 EST 2014
On Sat, 01 Mar 2014 19:29:41 +0200, Marko Rauhamaa wrote:
> Michael Torrie <torriem at gmail.com>:
>
>> No, '==' works fine no matter what objects you assign to your state
>> variables.
>
> Well, it doesn't since
>
> >>> a = float("nan")
> >>> a is a
> True
> >>> a == a
> False
No, that is working correctly, so the comment that equals works fine is
correct: returning False is the correct thing to do if one or both of the
objects are a NAN. NANs are supposed to compare unequal to everything,
including themselves.
The is operator and the == operator do not have the same purpose and they
do not do the same thing. "is" should not be considered an improved ==
without the quirks, this is not PHP and we're not comparing == and ===.
The argument here is not about which operator performs the check we want,
but over what check we want: do we want an identity test or an equality
test?
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list