Steven D'Aprano wrote:
> def compile_alternatives(*args):
Thank you all, for these good points. For my eyes seem that explicit or
implicit it will take some looping to concatenate the list elements into a
string.
I will see pypy later.
--
goto /dev/null
--
http://mail.python.org/mailman/lis
2011/6/16 TheSaint :
> Hello,
> Is it possible to compile a regex by supplying a list?
>
> lst= ['good', 'brilliant'. 'solid']
> re.compile(r'^'(any_of_lst))
>
> without to go into a *for* cicle?
>
In simple cases, you can just join the list of alternatives on "|" and
incorporate it in the pattern
On Thu, 16 Jun 2011 20:48:46 +0800, TheSaint wrote:
> Hello,
> Is it possible to compile a regex by supplying a list?
>
> lst= ['good', 'brilliant'. 'solid']
>
> re.compile(r'^'(any_of_lst))
>
> without to go into a *for* cicle?
How about this?
def compile_alternatives(*args):
alternati