diff lookup_list.py @ 110:8fa1ef2411a0

Worked on OneShotTLearner and implementation of LinearRegression
author bengioy@bengiomac.local
date Tue, 06 May 2008 22:24:55 -0400
parents 427e02ef0629
children b4657441dd65 ff6b7bfb6cdc
line wrap: on
line diff
--- a/lookup_list.py	Tue May 06 20:01:34 2008 -0400
+++ b/lookup_list.py	Tue May 06 22:24:55 2008 -0400
@@ -9,6 +9,7 @@
     following syntactic constructions work as one would expect:
        example = LookupList(['x','y','z'],[1,2,3])
        example['x'] = [1, 2, 3] # set or change a field
+       print example('z','y') # prints [3,2]
        x, y, z = example
        x = example[0]
        x = example["x"]
@@ -88,7 +89,6 @@
             new_example.append_keyval(item[0],item[1])
         return new_example
 
-        
     def __eq__(self, other):
         return self._values==other._values and self._name2index==other._name2index and self._names==other._names
 
@@ -97,3 +97,9 @@
 
     def __hash__():
         raise NotImplementedError()
+
+    def __call__(*names):
+        """
+        Return a list of values associated with the given names (which must all be keys of the lookup list).
+        """
+        return [self[name] for name in names]