inconsistency with += between different types ?

Christopher A. Craig list-python at ccraig.org
Wed Aug 7 18:52:18 CEST 2002


"Donn Cave" <donn at u.washington.edu> writes:

> The sad thing is, all this hand-waving is really germane to only one
> issue I can think of, an object's suitability for use as a hash key.

It is also relevant to a lot of things related to numbers.  All
references to the same integer reference the same object.  This means
that if integers were mutable then in theory the following result
could occur (a result, which I'll note is similar to something that
was actually possible in early versions of SmallTalk for reasons of
mutability).

>>> a=t=5
>>> t+=2
>>> t
7
>>> a
7
>>> 5
7

-- 
Christopher A. Craig <list-python at ccraig.org>
Linux: (n) "A microkernel on which one can run operating system kernels
such as XEmacs."  -- Froggie, from Everything




More information about the Python-list mailing list