Apologies for the top post, my phone doesn't allow editing the message body.

You are slightly confused - ints are not mutable! You can combine or
multiply them, along with several other operations, but they are certainly
not mutable. The easiest way to check is use them as keys in a dict. You
can't do that with lists or other mutable types. Since I don't have computer
access right now I can't look up the docs on id, but hopefully someone else
can enlighten you. But ints are definitely immutable. I suspect you're
confusing the fact that you can easily reassign ints with mutability.

HTH,
Wayne

On Jun 7, 2011 5:50 PM, "Válas Péter" <suli...@postafiok.hu> wrote:

Hi,

let X be a mutable container, such as dict/set/list=bytearray, and Y=X,
When I change X, Y will follow it, having always the same value, although
id(X)!=id(Y). How is that, what is the explanation? Meanwhile the same for
immutable types results a real copy, and so does for simple mutables such as
int.

I suspect it has something to do with pointers, but what is the difference
between mutables and immutables, and why have they different id's if they
are the same?

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to