python copy method alters type

Terry Reedy tjreedy at udel.edu
Thu May 14 23:56:06 CEST 2009


Zhenhai Zhang wrote:
> Really weired; Here is my code:
> 
>    a = ["a", 1, 3, 4]
>    print "a:", a
>      c = copy(a)

SyntaxError: unexpected indent
If you correct that, you would get a NameError

>    c[0] = "c"
>    c[1] = 2
>    print "c:", c
>    print "a:",a

When posting, copy and paste the complete code that you actually ran to 
get the purported output.




More information about the Python-list mailing list