Why is this?

Duncan Booth duncan.booth at invalid.invalid
Fri Aug 12 23:21:25 CEST 2005


Peter Mott wrote:

> But it is still true that [[]] + [[]] is not the same as [[]] * 2. In my 
> usage anyway this means that "S+S is the same as S*2" is false. Because 
> there are Python expressions for which it is falsfied.
> 
> The problem I have is pretty philosophical I admit, but I don't think 
> you do it justice. It's really about identity. 

So would you expect:

    random.seed(0)
    random.random() + random.random()

and:

    random.seed(0)
    random.random() * 2

to be the same? The first call to random() in each case returns the same 
result, but even though the source text is identical the second call 
in the addition returns something different. It is just the same with the 
lists.



More information about the Python-list mailing list