Pattern Matching Over Python Lists

MRAB google at mrabarnett.plus.com
Fri Jun 20 07:08:07 EDT 2008


On Jun 20, 1:45 am, Chris <chriss... at gmail.com> wrote:
> On Jun 17, 1:09 pm, bearophileH... at lycos.com wrote:
>
> > Kirk Strauser:
>
> > > Hint: recursion.  Your general algorithm will be something like:
>
> > Another solution is to use a better (different) language, that has
> > built-in pattern matching, or allows to create one.
>
> > Bye,
> > bearophile
>
> Btw, Python's stdlib includes a regular expression library. I'm not
> sure if you're trolling or simply unaware of it, but I've found it
> quite adequate for most tasks.

bearophile was talking about matching lists and tuples, not matching
strings.

Python's regular expression module works with characters in strings,
but the same approach can be applied to items in lists and tuples.



More information about the Python-list mailing list