> if x == None: > do_something() > > but then someone thought that we should really change these to > > if x is None: > do_something() > > However. if you run pychecker on these two snippets of code, it > complains about the second, and not the first:
Personally I'd use if not x: do_something() No idea what pyChecker thinks of that though! :-) And of course it's slightly different to a specific check for None, it will catch 0, [], '',"", etc... Of the two forms you suggest I'd stick with equality since the identity test (is) assumes that only one instance of None ever exists which could potentially change in some future exotic version of Python... You really are interested in the value of x not its identity. Alan G. _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
