why () is () and [] is [] work in other way?
Alexander Blinne
news at blinne.net
Sat Apr 21 04:46:39 EDT 2012
Am 21.04.2012 05:25, schrieb Rotwang:
> On 21/04/2012 01:01, Roy Smith wrote:
>> In article<877gxajit0.fsf at dpt-info.u-strasbg.fr>,
>> Alain Ketterlin<alain at dpt-info.u-strasbg.fr> wrote:
>>
>>> Tuples are immutable, while lists are not.
>>
>> If you really want to have fun, consider this classic paradox:
>>
>>>>> [] is []
>> False
>>>>> id([]) == id([])
>> True
>
> Huh. This is not what I would have expected. What gives?
This happens only because the first [] gets destroyed after evaluation
of id([]). The second [] then by accident gets the same id as the first
one had.
>>> a = []
>>> b = []
>>> id(a) == id(b)
False
Greetings
More information about the Python-list
mailing list