app/soc/logic/dicts.py
changeset 410 2af7f84f4fc7
parent 387 c55195361cb6
child 484 6364f8b0656b
--- a/app/soc/logic/dicts.py	Thu Oct 23 05:21:26 2008 +0000
+++ b/app/soc/logic/dicts.py	Thu Oct 23 05:21:41 2008 +0000
@@ -41,3 +41,28 @@
       target[key] = value
 
   return target
+
+def zip(keys, values):
+  """Returns a dict containing keys with values
+
+  If there are more items in keys than in values, None will be used.
+  If there are more items in values than in keys, they will be ignored.
+
+  Args:
+    keys: the keys for the dictionary
+    values: the values for the dictionary
+  """
+
+  result = {}
+
+  size = len(keys)
+
+  for i in range(size):
+    if i < len(values):
+      value = values[i]
+    else:
+      value = None
+    key = keys[i]
+    result[key] = value
+
+  return result