Preferred method for "Assignment by value"

Robin Stocker robin at
Tue Apr 15 21:25:43 CEST 2008

hall.jeff at schrieb:
> by changing temp = v[:] the code worked perfectly (although changing
> temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't
> like that as I knew it was a workaround)

So the for body now looks like this?:

   temp = v[:]
   temp.insert(0, k)

It can still be clarified and simplified to this (may also be faster):

   temp = [k] + v

Which one do you like better :)?


More information about the Python-list mailing list