Metal Zong wrote:
>
> The operator is and is not test for object identity: x is y is true if 
> and only if x and y are the same objects.
>
>  
>
> >>> x = 1
>
> >>> y = 1
>
> >>> x is y
>
> True
>
>  
>
> Is this right? Why? Thanks.
>
>  
>
Yes that is true, but it's an implementation defined optimization and 
could be applied to *any* immutable type.  For larger ints, such a thing 
is not true.
 >>> x=1000
 >>> y=1000
 >>> x is y
False

If either is a surprise, then understand that the "is" operator should 
probably *never* be used with immutable types.

Gary Herron

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to