On June 24, 2004 01:46 pm, Sebastian Haase wrote:
In general it must be OK to compare anything with None, right ? (BTW, I get the same error with == and !=)
No! Not in general! I learnt this back when Numeric implemented rich comparisions; suddenly, lots of my code broke. You don't actually want "is this object _equal_ (or not equal) to None", you want "is this object None", as None is a singleton.
A contrived example:
... def __eq__(self, other): return True ...
a = A()
So, this is bad:
a == None
This is good:
a is None
In general, if you're testing if something is None, use 'is', not '=='.
q.Mrc.hdr('title') is not None