"Mark blobby Robinson" <m.1.robinson at herts.ac.uk> wrote in message news:3AE706FE.719B091F at herts.ac.uk... > I needed a non-destructive method so popitem was not a viable option, but I In many cases it should not be a problem to 'restore' into _another_ dictionary. Or do you have many references to the starting dict which it would be a problem to update...? Then you can do the same trick again -- sure, it's gonna be slower, but... The general idea would be: newdic = {} while len(oldict): key, value = oldict.popitem() process(key, value) newdic[key] = value and now in newdic you have all you earlier had in oldict, and may pour it back if need be. Of course, not thread-safe, not fastest, &c, but still it may be useful. Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4