Prateek <[EMAIL PROTECTED]> writes: > > How about using (x, type(x)) as the key instead of just x? > Yup. I thought of that. Although it seems kinda unpythonic to do so. > Especially since the dictionary is basically a cache mostly containing > strings. Adding all the memory overhead for the extra tuples seems > like a waste just for those four keys.
You could use a second dict for the other type: def lookup(x): if x in dict1: return dict1[x] return dict2[x] dict1 would have the 4 special keys and dict2 would have the regular keys. -- http://mail.python.org/mailman/listinfo/python-list