"if x == None" raises "'NoneType' object is not callable"
Gerhard Häring
gerhard.haering at opus-gmbh.net
Mon Sep 16 09:27:46 EDT 2002
Luc Saffre wrote:
> row = Row()
> if row == None: # here it happens.
> print "row instance is None!"
To avoid this and similar problems in the future, test for None using the is
operator, like:
if row is None:
print "row instance is None!"
This way, row doesn't need to support comparison to None. The same holds true
for all other singletons you have in your app. As an additional plus,
'is'-comparison is faster.
-- Gerhard
More information about the Python-list
mailing list