Hello Guys,
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? Next up I'm looking to compare two different dictionaries, then loop through the unique results that are in each and print them out. Is there a more efficient way of doing this other than a loop with an if/else statement? For a in self.dict1: If a not in self.dict2: Print 'Found %s' % (a) For b in self.dict2: If b not in self.dict1: Print 'Found %s' % (b) That would firstly loop through the first dict and output any of its unique values, it then loops through the second dict and output any of its unique values, is this the best way of doing this? Or is there something more efficient? Thanks, Rob Rawlins
-- http://mail.python.org/mailman/listinfo/python-list