How to check if any item from a list of strings is in a big string?

Pablo Torres N. tn.pablo at gmail.com
Thu Jul 16 12:02:57 EDT 2009


On Thu, Jul 9, 2009 at 22:07, Steven
D'Aprano<steven at remove.this.cybersource.com.au> wrote:
> On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote:
>
>> def list_items_in_string(list_items, string):
>>     for item in list_items:
>>         if item in string:
>>             return True
>>     return False
> ...
>> Any ideas how to make that function look nicer? :)
>
> Change the names. Reverse the order of the arguments. Add a docstring.
>

Why reverse the order of the arguments? Is there a design principle there?

I always make a mess out of the order of my arguments...

-- 
Pablo Torres N.



More information about the Python-list mailing list