Reference

alex23 wuwei23 at gmail.com
Wed Mar 5 01:01:04 EST 2014


On 5/03/2014 3:47 PM, Rustom Mody wrote:
> That python is a hll means that machine reprs are intended to be abstracted
> away. 'is' fails to do that -- proof of that being the discrepancy between
> is and ==

The "discrepancy" is because _they're fundamentally different_:

     >>> a = b = [1,2]
     >>> c = [1,2]
     >>> a is b
     True
     >>> a is c
     False
     >>> a == b
     True
     >>> a == c
     True

`is` is used to determine if two names refer to the same object.
`==` is used to determine if they're equivalent in value.

Both have their uses.



More information about the Python-list mailing list