Mercurial > pylearn
diff lookup_list.py @ 144:ceae4de18981
Automated merge with ssh://p-omega1@lgcm.iro.umontreal.ca/tlearn
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 12 May 2008 15:08:18 -0400 |
parents | ad144fa72bf5 |
children | 4803cb76e26b |
line wrap: on
line diff
--- a/lookup_list.py Mon May 12 14:30:21 2008 -0400 +++ b/lookup_list.py Mon May 12 15:08:18 2008 -0400 @@ -71,6 +71,12 @@ self._values.append(value) self._names.append(key) + def append_lookuplist(self, *list): + for l in list: + for key in l.keys(): + self.append_keyval(key,l[key]) + del l + def __len__(self): return len(self._values) @@ -103,3 +109,15 @@ 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] + + +if __name__ == '__main__': + + a=LookupList(['a'],[1]) + print a + b=LookupList(['b'],[2]) + print b + a.append_lookuplist(b) + print a + a.append_lookuplist(b) + print a