app/soc/logic/dicts.py
changeset 719 2e635755713a
parent 499 d22e4fe8e64b
child 721 6f1d29857072
equal deleted inserted replaced
718:5f9b1676816d 719:2e635755713a
    87     key = keys[i]
    87     key = keys[i]
    88     result[key] = value
    88     result[key] = value
    89 
    89 
    90   return result
    90   return result
    91 
    91 
       
    92 
       
    93 def unzip(target, order):
       
    94   """Constructs a list from target in the order specified by order
       
    95 
       
    96   Args:
       
    97     target: the dictionary to pull the values from
       
    98     order: the order of the keys
       
    99   """
       
   100 
       
   101   return (target[key] for key in order)
       
   102 
       
   103 
    92 def rename(target, keys):
   104 def rename(target, keys):
    93   """Returns a dict containing only the key/value pairs from keys.
   105   """Returns a dict containing only the key/value pairs from keys.
    94 
   106 
    95   The keys from target will be looked up in keys, and the corresponding
   107   The keys from target will be looked up in keys, and the corresponding
    96   value from keys will be used instead. If a key is not found, it is skipped.
   108   value from keys will be used instead. If a key is not found, it is skipped.