On Fri, 18 Nov 2005 15:34:36 +0100, Gabriel Zachmann wrote:
> i don't see why there should be only one instance of Int with the value 0.
"Small" ints are cached, so there may be only one instance of the int with
value 0. However, that's an implementation detail, which may change from
version to v
> We've just had a HUGE thread arguing about this behaviour, just three or
> five days ago. Let's not start it again.
ok, could you please point me to it?
> In a nutshell, the behaviour is because ints are immutable and can't be
> changed in place, and lists are mutable and can be changed in plac
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Imagine that ints could be changed in place. Then you could do this:
>
> x = 0
> x += 1
No nothing like that. Nothing stops you from having multiple int
objects with the same value. Lists, for example, are mutable, but
x = [0,1]
x += [2,3]
doe
On Thu, 10 Nov 2005 22:43:53 +0100, Gabriel Zachmann wrote:
> It seems to me that the following behavior of python (2.4.1) is inconsistent:
We've just had a HUGE thread arguing about this behaviour, just three or
five days ago. Let's not start it again.
In a nutshell, the behaviour is because i
Gabriel Zachmann wrote:
> It seems to me that the following behavior of python (2.4.1) is
> inconsistent:
>
> >>> a=1
> >>> b=a
> >>> a+=1
> >>> b
> 1
> >>> a
> 2
> >>> a=[1,2]
> >>> b=a
> >>> b+=[3]
> >>> a
> [1, 2, 3]
> >>> b
> [1, 2, 3]
>
> Why was it implemented like this??
assuming
Gabriel Zachmann wrote:
> It seems to me that the following behavior of python (2.4.1) is inconsistent:
[snip]
> Why was it implemented like this??
Lists are mutable objects; integers are not. For a list, a += b is
equivalent to a.__iadd__(b), which is an in-place modification.
For an integer, no
It seems to me that the following behavior of python (2.4.1) is inconsistent:
>>> a=1
>>> b=a
>>> a+=1
>>> b
1
>>> a
2
>>> a=[1,2]
>>> b=a
>>> b+=[3]
>>> a
[1, 2, 3]
>>> b
[1, 2, 3]
Why was it implemented like this??
Best regards,
Gabriel.
--
/