Added an identity function to dicts
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 13 Mar 2009 23:11:16 +0000
changeset 1842 391b89d04bdd
parent 1841 d7ac10b583fb
child 1843 af89d570bf6f
Added an identity function to dicts Patch by: Sverre Rabbelier
app/soc/logic/dicts.py
--- a/app/soc/logic/dicts.py	Fri Mar 13 23:10:49 2009 +0000
+++ b/app/soc/logic/dicts.py	Fri Mar 13 23:11:16 2009 +0000
@@ -207,3 +207,10 @@
 
   result = ((k, v[new_key]) for k, v in target.iteritems() if v[key])
   return dict(result)
+
+def identity(target):
+  """Returns a dictionary with the values equal to the keys.
+  """
+
+  result = [(i, i) for i in target]
+  return dict(result)