On Mon, 30 Apr 2007 09:40:53 +0100, Tim Golden wrote: > Robert Rawlins - Think Blue wrote: >> I'm looking for a little advice on dicts, firstly I need to learn how to >> copy a dict, I suppose I could just something like. > >> Self.newdict = self.olddict > >> But I fear that this only creates a reference rather than an actual copy, >> this means that as soon as I clear out the old one, the new one will >> effectively be empty. What's the best way to ACTUALY copy a dict into a new >> variable? > > Unless you have specialised needs, you can just say: > > d2 = dict (d1)
Or you can say d2 = d1.copy() -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list