On Dec 23, 5:38 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | >>> def spam2(x, s=re.compile('nobody expects the Spanish > Inquisition!')): > | ... return s.search(x) > | > | I suspect that this will be not only the fastest solution, but also the > | most flexible. > > 'Most flexible' in a different way is > > def searcher(rex): > crex = re.compile(rex) > def _(txt): > return crex.search(txt) > return _ >
I see your obfuscatory ante and raise you several dots and underscores: class Searcher(object): def __init__(self, rex): self.crex = re.compile(rex) def __call__(self, txt): return self.crex.search(txt) Cheers, John -- http://mail.python.org/mailman/listinfo/python-list