How to improve this code?

Andreas Waldenburger usenot at geekmail.INVALID
Tue Sep 15 19:06:08 CEST 2009


On Mon, 14 Sep 2009 18:33:17 -0700 (PDT) André
<andre.roberge at gmail.com> wrote:

> Here's an example using sets:
> 
> >>> def is_present(list_1, list_2):
> ...    if set(list_1).intersection(set(list_2)):
> ...       return True
> ...    return False
> ...

Not that it matters, but I'd probably write:

def is_present(test, match):
    return bool(set(test) & set(match))

/W

-- 
INVALID? DE!




More information about the Python-list mailing list