in operator for strings

Fredrik Lundh fredrik at pythonware.com
Tue May 25 06:08:13 EDT 2004


"Moosebumps" wrote:

> Wouldn't it be cool if you could do this?
>
> ('hello','test') in 'blah blah hello blah test':
>
> and it would say if all elements of the list are in the string?

well, if you're asking me, I'd say that what's really cool is that you
can do not only

    findall(('hello', 'test'), 'blah blah hello blah test')

but also

    find_any(('hello', 'test'), 'blah blah hello blah test')

    find_in_order(('hello', 'test'), 'blah blah hello blah test')

    find_in_any_case(('hello', 'test'), 'blah blah hello blah test')

    starts_and_ends_with(('hello', 'test'), 'blah blah hello blah test')

    find_only_on_fridays(('hello', 'test'), 'blah blah hello blah test')

etc.

without having to change the language, or any of its implementations.

</F>







More information about the Python-list mailing list