On Jun 17, 2013, at 6:17, Νίκος <supp...@superhost.gr> wrote:
> On 16/6/2013 9:53 μμ, R. Michael Weylandt wrote: >> On Sun, Jun 16, 2013 at 2:47 PM, Ferrous Cranus <supp...@superhost.gr> wrote: >>> On 16/6/2013 2:13 μμ, Jussi Piitulainen wrote: >>>> >>>> If, instead of the above, you have >>>> >>>> a = 6 >>>> b = a >>>> b = 5 >>>> >>>> you will find that b == 5 and a == 6. So b is not the same as a. Else >>>> one would have changed when the other changed. I would say that a and >>>> b are different variables. They had the same value, briefly. >>> >>> >>> If they were different variables then they would have different memory >>> addresses and they would act like two different objects. >>> >>> But... both a and b are for a fact mappings for the same memory address as >>> seen form the following command. >>> >>>>>> id(a) == id(b) >>> True >>> >>> They are like the same object with 2 different names. >> >> This will depend on when the test is run: >> >> a = 6 >> b = a >> a is b # True >> >> b = 5 >> a is b # False >> >> The latter is false because the binding of "b" to the int 6 was broken >> in order to bind b to the int 5. > > Very surprising. > a and b was *references* to the same memory address, it was like a memory > address having 2 names to be addresses as. > > b = a name we use to address some memory location, do we agree on that? > > So, b = 6, must have changed the stored value of its mapped memory location, > but given you example it seems its changing the mapping of b to some other > memory address. > > I don't follow its act of course. I'm having trouble understanding your grammar in the above, but please re-read my note on the dual behavior of `=` here: http://mail.python.org/pipermail/python-list/2013-June/649990.html Michael
-- http://mail.python.org/mailman/listinfo/python-list