Anton

Erik Max Francis max at alcyone.com
Fri May 23 03:54:26 EDT 2003


Quiet wrote:

> a = [1, 2, 3]
> b = a
> 
> b is alias a.
> 
> In other cases the new object is created.
> 
> a = 34
> b = a
> 
> b is new object.

No it isn't:

>>> a = [1, 2, 3]
>>> b = a
>>> a is b
1
>>> a = 34
>>> b = a
>>> a is b
1

What's probably confusing you is that integers, unlike lists, are
immutable, so getting a reference to an integer guarantees that the
integers you're referring to can never change (because no integers can).

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ There is nothing stronger in the world than gentleness.
\__/  Han Suyin




More information about the Python-list mailing list