Proposal: === and !=== operators
python.list at tim.thechases.com
Wed Jul 9 20:05:22 CEST 2014
On 2014-07-09 12:48, Steven D'Aprano wrote:
> On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote:
> > We would have *three* ways to compare for equality (==, ===, and
> > is).
> `is` does not, never has, and never will, be a test for equality.
> py> x = 
> py> y = 
> py> x is y
I too am in the -1 category for adding an extra operator-suite
because of the confusion it will add (this is one of my biggest
pet peeves with PHP/JS).
If you want to compare things in a NaN-aware way, you can either
spell it out explicitly:
if x == y or (math.isnan(x) and math.isnan(y)):
or create a wrapper function to do that for you:
def equalish(x, y):
return x == y or (math.isnan(x) and math.isnan(y))
if equalish(w, z):
More information about the Python-list