A more pythonic way of writting

Mark Tolonen metolone+gmane at gmail.com
Fri Dec 5 09:44:35 EST 2008


"eric" <eric at ericaro.net> wrote in message 
news:35d176ed-df5f-46b4-8321-4814fcc4398c at f3g2000yqf.googlegroups.com...

> def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False,
> DOTALL=False, UNICODE=False, VERBOSE=False):
>    vals = [IGNORECASE, LOCALE, MULTILINE, DOTALL, UNICODE, VERBOSE]
>    filtered = map( lambda m:m[1],filter( lambda m: m[0], 
> zip(vals,'iLmsux')))
>    return '?'+''.join( filtered  )

    filtered = [c for c,v in zip('iLmsux',vals) if v]

-Mark





More information about the Python-list mailing list