Mercurial > pylearn
changeset 137:ff6b7bfb6cdc
added function LookupList.append_lookuplist
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Wed, 07 May 2008 17:01:51 -0400 |
parents | fa752c55aa09 |
children | 86bc934a7518 |
files | lookup_list.py |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lookup_list.py Wed May 07 16:26:28 2008 -0400 +++ b/lookup_list.py Wed May 07 17:01:51 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