"if x == None" raises "'NoneType' object is not callable"
gerhard.haering at opus-gmbh.net
Mon Sep 16 15:27:46 CEST 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
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.
More information about the Python-list