id == vs is

Ethan Furman ethan at stoneleaf.us
Sun Oct 26 20:23:32 EDT 2014


On 10/26/2014 05:12 PM, Dan Stromberg wrote:
> Are the following two expressions the same?
>
> x is y
>
> Id(x) == id(y)
>
> ?

Nope.  If the value if `id(x)` is not interned, then the two value could be different objects that still represent the 
same value.

--
~Ethan~



More information about the Python-list mailing list