Fwd: Checking a string against multiple matches

2008-12-03 Thread wu wei
list? I've asked him to stop but he rather abusively replied saying that he wasn't doing anything wrong. -- Forwarded message -- From: Stephen Meredith <[EMAIL PROTECTED]> Date: Tue, Dec 2, 2008 at 11:08 AM Subject: Re: Checking a string against multiple matches To

Re: Checking a string against multiple matches

2008-12-02 Thread alex23
On Dec 2, 10:09 pm, Chris <[EMAIL PROTECTED]> wrote: > On Dec 2, 3:01 am, alex23 <[EMAIL PROTECTED]> wrote: > > The only time I'd expect it to do partial matches is if you were doing > > string.index(string), rather than list.index(string): > It would if the OP was iterating over the list and chec

Re: Checking a string against multiple matches

2008-12-02 Thread Chris
On Dec 2, 3:01 am, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 2, 5:31 am, Aaron Scott <[EMAIL PROTECTED]> wrote: > > > I was using .index on the > > list, but it would return True for strings that contained the search > > string rather than match it exactly, leading to false positives in my > > cod

Re: Checking a string against multiple matches

2008-12-01 Thread alex23
On Dec 2, 5:31 am, Aaron Scott <[EMAIL PROTECTED]> wrote: > I was using .index on the > list, but it would return True for strings that contained the search > string rather than match it exactly, leading to false positives in my > code. Are you sure? That doesn't seem like standard behaviour. >>>

Re: Checking a string against multiple matches

2008-12-01 Thread Jerry Hill
On Mon, Dec 1, 2008 at 3:29 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Damn you, Python, and your loose documentation! It never occurred to > me to actually TRY my pseudocode, since I couldn't find anything on > that type of statement. Anyway, feel free to ignore me from now on. I'm not sure whe

Re: Checking a string against multiple matches

2008-12-01 Thread Aaron Scott
Damn you, Python, and your loose documentation! It never occurred to me to actually TRY my pseudocode, since I couldn't find anything on that type of statement. Anyway, feel free to ignore me from now on. -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking a string against multiple matches

2008-12-01 Thread Peter Otten
Aaron Scott wrote: > I've been trying to read up on this, but I'm not sure what the > simplest way to do it is. > > I have a list of string. I'd like to check to see if any of the > strings in that list matches another string. > > Pseudocode: > > if "two" in ["one", "two", "three", "four"]: >

Re: Checking a string against multiple matches

2008-12-01 Thread Jerry Hill
On Mon, Dec 1, 2008 at 2:31 PM, Aaron Scott <[EMAIL PROTECTED]> wrote: > Pseudocode: > > if "two" in ["one", "two", "three", "four"]: > return True That works, just like you wrote it: >>> "two" in ["one", "two", "three", "four"] True >>> "two" in ["one", "twofer", "three", "four"] False If

Checking a string against multiple matches

2008-12-01 Thread Aaron Scott
I've been trying to read up on this, but I'm not sure what the simplest way to do it is. I have a list of string. I'd like to check to see if any of the strings in that list matches another string. Pseudocode: if "two" in ["one", "two", "three", "four"]: return True Is there any built-in i