Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror

Comment Re:Leaky abstractions (Score 1) 175

Well, thats because python, to save memory and processing time with lists, passes by reference, not by copy. The way to do what you want is this: >>> a=[[5]] >>> b=[a[0][:]] >>> a[0][0]=3 >>> b [[5]] However, if you are going to be passing around lists, and want copies to modify, then do this: b=a[:] to do a one-level copy of the list's contents. Any lists in the list, as above, will also be passed by reference, not copy. If you do have nested lists, then take a look at the copy module.

"The number of Unix installations has grown to 10, with more expected." -- The Unix Programmer's Manual, 2nd Edition, June, 1972

Working...