Confusion: assignments create object references.

Havens, Peter Peter.Havens at Level3.com
Fri Apr 11 12:52:36 EDT 2003


// -----Original Message-----
// From: Jp Calderone [mailto:exarkun at intarweb.us]
//
// > So far so good. This works as I would expect given the rule above.
// > 
// > >>> L = 0
// > >>> M = L
// > >>> L
// > 0
// > >>> M = 1
// > >>> L
// > 1
// > >>>
// > 
// 
//   The above never happened, I assure you. >:)    Python 
// doesn't work this way.

I'm a silly rabbit. I hand copied the test incorrectly. The real test was:

>>> L = 1
>>> M = L
>>> L
1
>>> M = 0
>>> L
1
>>>

Those are the real results (I double checked), but now I'm really confused. Why does the former test (the one I lied about) above give expected results, and the later doesn't?





More information about the Python-list mailing list