On 08/12/11 09:03, sunil tech wrote:
/Can i copy the content if a dictionary in to another variable, with out
any link between the dictionary & the variable?

if so, please teach.

Yes, but they will both refer to the same object.
But the two references will be entirely independant:

D = {1:2,3:4}
d = D[1]       # both d and D[1] reference 2

D[1] = 42      # d still refers to 2

del(D)         # d still refers to 2

Is that what you mean?

Or do you wantbto make a clone of the value so that you
can change it without changing the original?

In that case you can use several techniques depending on object type. Generically use copy or deepcopy.

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to