On 10/02/07, Cecilia Alm <[EMAIL PROTECTED]> wrote: > Why does the identity operator return "True" in the below cases, that is > when assigning the same value to basic variable types (float, integer, > string, bool..)? Are these rcopied by reference (shallow)? If so why? > > >>> i = 10 > >>> j = 10 > >>> i is j > True
Effectively, yes. Integers in python are immutable. I'm not sure exactly what happens under the hood, but you can think of it like there is only one 10 in the interpreter's memory, and every name you give it is just a pointer to that one 10. Remember, python is fully OO -- _everything_ is a reference :-) (this is also why there is no ++ operator) -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor