On 08/09/2010 06:11 AM, saeed.gnu wrote: > On Aug 9, 3:41 pm, "saeed.gnu" <saeed....@gmail.com> wrote: >> "x is y" means "id(y) == id(y)" >> "x is not y" means "id(x) != id(x)" >> "x is not None" means "id(x) != id(None)" >> >> "x is not None" is a really silly statement!! because id(None) and id >> of any constant object is not predictable! I don't know whay people >> use "is" instead of "==". you should write "if x!=None" instead of "x >> is not None" > > Although small objects are unique in the memory (with a unique id) and > using "is" works ok, but that's not logical to compare id's when we > actually want to compare values!
Sounds like you're confusing Python's namespace with variables. When I say: a = None I'm binding the None object to the a name. Thus a *is* None. While in theory "None" does have a value, doing "a is None" is much more explicit and clearer than "a == None" although perhaps the result is the same. In any event "a is None" is actually logical because that's what I'm normally interested in. Whether or not a is None. I don't really care about the value of None. -- http://mail.python.org/mailman/listinfo/python-list