Re: is dict.copy() a deep copy or a shallow copy

2005-09-05 Thread Alex
Thanks max, Now it's much clearer. I made the following experiment #1 D={'a':1, 'b':2} D {'a': 1, 'b': 2} E=D.copy() E {'a': 1, 'b': 2} D['a']=3 D {'a': 3, 'b': 2} E {'a': 1, 'b': 2} #2 D={'a':[1,3], 'b':[2,4]} D {'a': [1, 3], 'b': [2, 4]} E=D.copy() E {'a': [1, 3], 'b': [2, 4]}

is dict.copy() a deep copy or a shallow copy

2005-09-04 Thread Alex
Entering the following in the Python shell yields help(dict.copy) Help on method_descriptor: copy(...) D.copy() - a shallow copy of D Ok, I thought a dictionary copy is a shallow copy. Not knowing exactly what that meant I went to http://en.wikipedia.org/wiki/Deep_copy where I could read

Re: is dict.copy() a deep copy or a shallow copy

2005-09-04 Thread Max Erickson
Alex [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: D={'Python': 'good', 'Basic': 'simple'} E=D.copy() E {'Python': 'good', 'Basic': 'simple'} D['Basic']='oh my' D {'Python': 'good', 'Basic': 'oh my'} E {'Python': 'good', 'Basic': 'simple'} Hmm, this looks like a deep copy to