On Mon, Mar 7, 2011 at 9:08 AM, Laura Creighton <l...@openend.se> wrote: > Singleton objects such as ``True``, ``False``, and ``None`` are always > the same object. The canonical way to test whether an object is > a singleton is to test for object identity, not equality. So > >>>> if x is None: > ... do something ... > > not > >>>> if x == None: > ... do something ...
Careful with that - "if x is True:" and "if x is False:" (along with s/is/==/) are almost always the wrong thing to do, but a reader could easily generalise the above to cover those two cases as well. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Doc-SIG maillist - Doc-SIG@python.org http://mail.python.org/mailman/listinfo/doc-sig