In article <52562ee3$0$2931$c3e8da3$76491...@news.astraweb.com>, Steven D'Aprano <st...@pearwood.info> wrote:
> Just came across this little Javascript gem: > > ",,," == Array((null,'cool',false,NaN,4)); > > => evaluates as true > > http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array > > I swear, I am never going to complain about Python again. I've just finished reading JavaScript: The Good Parts, by Douglas Crockford (now I'm working on the harder part of re-reading it slowly, to make sure I really understand it). Anybody who is forced to work with javascript should read this book. It's the K&R of JS. Anyway, one of the pieces of advice he gives is to pretend that == doesn't exist, and always use ===. PHP suffers from much the same problem. BTW, here's a Python equality oddity: >>> r = 0.0 >>> c = 0 + 0j >>> r == c True >>> int(r) == int(c) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't convert complex to int If x == y, then f(x) should also equal f(y). More specifically, if x == y, and x is in the domain of f(), then y should also be in the domain of f(). BTW, one of the earliest things that turned me on to Python was when I discovered that it uses j as the imaginary unit, not i. All right-thinking people will agree with me on this. -- https://mail.python.org/mailman/listinfo/python-list