[EMAIL PROTECTED] wrote:

>> >>> a = 1
>> >>> b = 1
>> >>> a is b
>> True
>> >>> id(a)
>> 10901000
>> >>> id(b)
>> 10901000
> 
> Isn't this because integers up to a certain range are held in a single
> memory location, thus why they are the same?
> 
Yes, in *some* implementations of Python this is exactly what happens. The 
exact range, or indeed whether it happens at all, and (if it does happen) 
whether the range depends on the phase of the moon are all undefined.

This, for example, is what I just got for a similar sequence:

>>> a = 1
>>> b = 5-4
>>> a is b
False
>>> id(a)
43L
>>> id(b)
44L
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to