why () is () and [] is [] work in other way?

Rotwang sg552 at hotmail.co.uk
Sat Apr 21 08:14:18 EDT 2012


On 21/04/2012 09:46, Alexander Blinne wrote:
> 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.

Thanks.


-- 
Hate music? Then you'll hate this:

http://tinyurl.com/psymix



More information about the Python-list mailing list