[Tutor] Copying Variables

Ryan Strunk ryan.strunk at gmail.com
Sun Jul 24 06:29:44 CEST 2011


Hello everyone,
How can I make two copies of a dictionary that don't point to the same
location in memory? My plan is to generate d1 and make d2 a copy of d1.
After the user modifies d1 I want him/her to be able to return to the
initial dictionary (d2) values. I tried:
d1 = {values}
d2 = dict(d1)
then later in the code when I want to re-initialize d1:
d1 = dict(d2)
but this won't work. Any suggestions you have as to how I can make this work
are welcome.
Best,
Ryan



More information about the Tutor mailing list