Raymond Hettinger <[EMAIL PROTECTED]> wrote: ... > The intersection step is unnecessary, so the answer can be simplified a > bit: > > >>> filter(set(l2).__contains__, l1) > [5, 3] > >>> filter(set(l1).__contains__, l2) > [3, 5]
...and if one has time to waste, "setification" being only an optimization, it can also be removed: filter(l2.__contains__, l1) etc (very slow for long lists, of course). Personally, I'd always use (depending on guesses regarding lengths of lists) [x for x in l1 if x in l2] or the setified equivalent, of course. Alex -- http://mail.python.org/mailman/listinfo/python-list