> Not entirely sure I understand you, can you post an example? > > If what you mean is that you need to locate the function (lambda) when > you know its corresponding strings, a dict will suit you just fine. > Either maintain two dicts for the two separate strings (eg if they're > "name" and "location" and you know whether you're looking up a name or > a location), or maintain a single dict with two entries per tuple (one > for each string). That gives you efficient and clean lookups.
Hey guys, Basically I have several mappings like the following: 'string_a', 'string_b', lambda s: ... I need to be able to index a mapping (there are ~100) by either string_a or string_b and at one point with one of those strings I would pull the lambda or the other string. The important part is getting the row by either of the two strings. I know I could just subclass dict and look it up the hardway with __missing__, just wondered if something elegant existed already. I may only know string_b and need string_a and the lambda. Thanks! jlc -- https://mail.python.org/mailman/listinfo/python-list