id == vs is

Ethan Furman ethan at stoneleaf.us
Mon Oct 27 01:23:32 CET 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