Confusion: assignments create object references.

Robin Munn rmunn at pobox.com
Mon Apr 14 11:05:44 EDT 2003


Jp Calderone <exarkun at intarweb.us> wrote:
> On Fri, Apr 11, 2003 at 10:28:42AM -0600, Havens, Peter wrote:
>> 
>> >>> L = 0
>> >>> M = L
>> >>> L
>> 0
>> >>> M = 1
>> >>> L
>> 1
>> >>>
>> 
> 
>   The above never happened, I assure you. >:)    Python doesn't work this
> way.

Indeed. I cannot reproduce this behavior either:

[rmunn at localhost ~]$ python
Python 2.2.2 (#1, Jan 12 2003, 12:07:20)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> L = 0
>>> M = L
>>> L
0
>>> M = 1
>>> L
0
>>>

Try it again. Do you still get the same result?

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838




More information about the Python-list mailing list