What's wrong with `is not None`?
Stefan Behnel
behnel_ml at gkec.informatik.tu-darmstadt.de
Wed Feb 9 06:50:02 EST 2005
Frans Englich schrieb:
> What is the equivalent expression which is more secure; `!= None`?
Note that this is not necessarily equivalent. '!=' and '==' possibly run
method calls on objects which can be costly depending on their
implementation and can even raise exceptions if called with None. If I
want to check for None, I always do it with "is". It's a constant after all...
Stefan
More information about the Python-list
mailing list