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
Ben Bush wrote:
On Dec 26, 4:46 pm, Tim Chase wrote:
What does *not* work is
3 * [0,1,2]
As you know, this gives
[0,1,2,0,1,2,0,1,2]
What I am hoping for is
[0,3,6]
I see that I can use
numpy.multiply(3,range(3))
but this seems overkill to me. Can you tell I am
Ben Bush wrote:
Hi,
I saw this line of code on a recent post:
a1[:] = [x*3 for x in a1]
Could somebody tells me what the [:] means? I can't find it anywhere.
It's a slice assignment. When both the start and stop arguments are omitted, it
refers to the entire sequence. In this case, it means