prefix matching

Christian Gudrian Christian.Gudrian at gmx.de
Wed May 26 16:12:35 EDT 2004


"Jeff Epler" <jepler at unpythonic.net> wrote:

>     def startswith_one(s, prefixes):
>         for p in prefixes:
>             if s.startswith(p): return True
>         return False

Thanks! startswith sounds good.

> If speed is important and "prefixes" doesn't change frequently, then
> coding a FSM in C is the way to go.

The prefixes don't change very often but can be configured by the user. So a
FSM is not the preferred approach here I think. And speed does not really
matter.

Christian





More information about the Python-list mailing list