diff lookup_list.py @ 45:a5c70dc42972

Test functions for dataset.py
author bengioy@grenat.iro.umontreal.ca
date Tue, 29 Apr 2008 11:25:36 -0400
parents b6b36f65664f
children 427e02ef0629
line wrap: on
line diff
--- a/lookup_list.py	Mon Apr 28 13:52:54 2008 -0400
+++ b/lookup_list.py	Tue Apr 29 11:25:36 2008 -0400
@@ -46,9 +46,11 @@
         The key in example[key] can either be an integer to index the fields
         or the name of the field.
         """
-        if isinstance(key,int):
+        if isinstance(key,int) or isinstance(key,slice) or isinstance(key,list):
             return self._values[key]
         else: # if not an int, key must be a name
+            # expecting key to be a valid field name
+            assert isinstance(key,str)
             return self._values[self._name2index[key]]
     
     def __setitem__(self,key,value):