On Tue, Jun 17, 2008 at 11:29 AM, pirata <[EMAIL PROTECTED]> wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: > ... > > if a is not b: > ... > > > What's the difference between "is not" and "!=" or they are the same thing?
The 'is' is used to test do they point to the exactly same object. The '==' is used to test are their values equal. same objects are equal, but equal don't have to be the same object. and be very careful to the dirty corner of python: >>> a = 100000 >>> b = 100000 >>> a is b False >>> a == b True >>> a = 5 >>> b = 5 >>> a is b True >>> a == b True >>> which is caused by small object cache mechanism. -- Best Regards, Leo Jay -- http://mail.python.org/mailman/listinfo/python-list