I got a question in this context.
suppose
a={'a': 3, 'b': [1, 2], 5: 100}
------------------b=a --------------    vs----------
b=copy.copy(a)------------
----------------------------------------------------
b[5]=6   ----------------------------------------      b[5]=6
output: -----------------------------------------      output:
b={'a': 3, 'b': [1, 2], 5: 6}-------------------     b={'a': 3, 'b': [1, 2],
5: 6}
a={'a': 3, 'b': [1, 2], 5: 6} -------------------    a={'a': 3, 'b': [1, 2],
5: 100}
that means b=a & b=copy.copy(a) aren't the same.
but
b['b'].append(3)
output:
b={'a': 3, 'b': [1, 2, 3], 5: 100}--------------b={'a': 3, 'b': [1, 2, 3],
5: 100}
a={'a': 3, 'b': [1, 2, 3], 5: 100}--------------a={'a': 3, 'b': [1, 2, 3],
5: 100}
now doesn't it mean that b=a & b=copy.copy(a) both are same?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to