Efficiently test for positive re.match then use the result?

elmlish elmlish at netscape.net
Wed Mar 3 21:53:18 CET 2004

> What's wrong with:
> alist =3D ['boo','hoo','choo']
> for line in alist:
>     m =3D re.match('choo', line)
>     if m:
>         doSomethingWith(m.groups(0))
> FuManChu

Nothing, really.. I was just hoping I could do that in even fewer steps.  
You know, the search for eternally overreaching brevity...

Thanks though.



More information about the Python-list mailing list