On Wed, 3 Mar 2010 07:46:39 pm Alan Gauld wrote: > mylist = [irtem for item in aList where item != None]
Comparisons with None almost always should be one of: item is None item is not None The reason is that "item is None" is ONLY ever true if the item actually is the singleton object None (accept no substitutes!). On the other hand, "item == None" might be true for some customer items. So if you actually *do* want to accept substitutes, you can use ==, but that would be an unusual thing to do, and worthy of a comment explaining that you did mean == and it isn't a mistake. Likewise for "item != None" versus "item is not None". -- Steven D'Aprano _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor