assignment with [:]

James Stroud jstroud at mbi.ucla.edu
Sun Dec 28 05:56:29 EST 2008


James Stroud wrote:
> py> a = [1, 2, 3]
> py> a1 = a
> py> a1[:] = [x*3 for x in a1]
> py> a1
>     [3, 6, 9]
> py> a1
>     [3, 6, 9]


This should have been:

py> a = [1, 2, 3]
py> a1 = a
py> a1[:] = [x*3 for x in a1]
py> a
     [3, 6, 9]
py> a1
     [3, 6, 9]


James


-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA  90095

http://www.jamesstroud.com



More information about the Python-list mailing list