Can global variable be passed into Python function?
Marko Rauhamaa
marko at pacujo.net
Sat Mar 1 12:29:41 EST 2014
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
More generally, it depends on how the __eq__ method has been implemented
for the class. You might even (foolishly) define a class such that:
>>> a == b
False
>>> a != b
False
The "is" operator is immune to such modality.
Marko
More information about the Python-list
mailing list