On Thu, 16 Jul 2009 11:02:57 -0500, Pablo Torres N. wrote:
> On Thu, Jul 9, 2009 at 22:07, Steven
> D'Aprano 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:
>>>
On Thu, Jul 9, 2009 at 22:07, Steven
D'Aprano 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 tha
Hi all,
This was more a question of programming aesthetics for me than one of
great practical significance. I was looking to perform a certain
function on files in a directory so long as those files weren't found
in certain standard directories. In other words, I was using os.walk
() to get mult
Sure, Aho-Corasick is fast for fixed strings; but without real
numbers / a concrete goal
> > Matt, how many words are you looking for, in how long a string ?
a simple solution is good enough, satisficing. Matt asked "how to
make that function look nicer?"
but "nice" has many dimensions -- bicycle
Nobody wrote:
On Tue, 14 Jul 2009 02:06:04 -0300, Gabriel Genellina wrote:
Matt, how many words are you looking for, in how long a string ?
Were you able to time any( substr in long_string ) against re.compile
( "|".join( list_items )) ?
There is a known algorithm to solve specifically this pro
On Tue, 14 Jul 2009 02:06:04 -0300, Gabriel Genellina wrote:
>> Matt, how many words are you looking for, in how long a string ?
>> Were you able to time any( substr in long_string ) against re.compile
>> ( "|".join( list_items )) ?
>
> There is a known algorithm to solve specifically this proble
En Mon, 13 Jul 2009 10:11:09 -0300, denis
escribió:
Matt, how many words are you looking for, in how long a string ?
Were you able to time any( substr in long_string ) against re.compile
( "|".join( list_items )) ?
There is a known algorithm to solve specifically this problem
(Aho-Corasic
Matt, how many words are you looking for, in how long a string ?
Were you able to time any( substr in long_string ) against re.compile
( "|".join( list_items )) ?
(REs are my method of choice, but different inputs of course give
different times --
see google regex speed site:groups.google.com /
sit
Thanks all!! I found the following to be most helpful: any(substr in
long_string for substr in list_of_strings)
This bang-for-your-buck is one of the many many reasons why I love
Python programming :)
Matt Dubins
--
http://mail.python.org/mailman/listinfo/python-list
inkhorn writes:
> def list_items_in_string(list_items, string):
> for item in list_items:
> if item in string:
> return True
> return False
You could write that as (untested):
def list_items_in_string(list_items, string):
return any(item in string for item in l
On Jul 10, 12:53 pm, Nobody wrote:
> On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote:
> > For one of my projects, I came across the need to check if one of many
> > items from a list of strings could be found in a long string.
>
> If you need to match many strings or very long strings against th
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 o
On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote:
> For one of my projects, I came across the need to check if one of many
> items from a list of strings could be found in a long string.
If you need to match many strings or very long strings against the same
list of items, the following should (
On Thu, Jul 9, 2009 at 6:36 PM, inkhorn wrote:
> Hi all,
>
> For one of my projects, I came across the need to check if one of many
> items from a list of strings could be found in a long string. I came
> up with a pretty quick helper function to check this, but I just want
> to find out if there'
Hi all,
For one of my projects, I came across the need to check if one of many
items from a list of strings could be found in a long string. I came
up with a pretty quick helper function to check this, but I just want
to find out if there's something a little more elegant than what I've
cooked up
15 matches
Mail list logo