Re: What is wrong in my list comprehension?

2009-02-02 Thread J Kenneth King
Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring is not in the given

Re: What is wrong in my list comprehension?

2009-02-02 Thread J Kenneth King
Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring is not in the given

Re: What is wrong in my list comprehension?

2009-02-02 Thread Stephen Hansen
str.find() returns -1 on failure (i.e. if the substring is not in the given string). -1 is considered boolean true by Python. That's an odd little quirk... never noticed that before. I just use regular expressions myself. Wouldn't this be something worth cleaning up? It's a little

Re: What is wrong in my list comprehension?

2009-02-02 Thread Peter Otten
J Kenneth King wrote: Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring

Re: What is wrong in my list comprehension?

2009-02-02 Thread MRAB
J Kenneth King wrote: Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring is

Re: What is wrong in my list comprehension?

2009-02-02 Thread J Kenneth King
Stephen Hansen apt.shan...@gmail.com writes: str.find() returns -1 on failure (i.e. if the substring is not in the given string). -1 is considered boolean true by Python. That's an odd little quirk... never noticed that before. I just use regular expressions myself. Wouldn't this be

Re: What is wrong in my list comprehension?

2009-02-02 Thread Stephen Hansen
I'm only curious if it's worth cleaning up because the OP's case is one where there is more than one way to do it. I just think at this point .find is just not the right method to use; substring in string is the way to determine what he wants is all. .find is useful for when you want the

Re: What is wrong in my list comprehension?

2009-02-02 Thread rdmurray
Quoth Stephen Hansen apt.shan...@gmail.com: I just think at this point .find is just not the right method to use; substring in string is the way to determine what he wants is all. .find is useful for when you want the actual position, not when you just want to determine if there's a match at

Re: What is wrong in my list comprehension?

2009-02-02 Thread Jason Scheirer
On Feb 1, 3:37 am, Peter Otten __pete...@web.de wrote: Hussein B wrote: Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime start = datetime.now()

Re: What is wrong in my list comprehension?

2009-02-02 Thread Peter Otten
Jason Scheirer wrote: On Feb 1, 3:37 am, Peter Otten __pete...@web.de wrote: Hussein B wrote: Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime

Re: What is wrong in my list comprehension?

2009-02-02 Thread J Kenneth King
Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring is not in the given

Re: What is wrong in my list comprehension?

2009-02-02 Thread J Kenneth King
Chris Rebert c...@rebertia.com writes: Python 2.6 (r26:66714, Nov 18 2008, 21:48:52) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. bool(-1) True str.find() returns -1 on failure (i.e. if the substring is not in the given

Re: What is wrong in my list comprehension?

2009-02-01 Thread Chris Rebert
On Sun, Feb 1, 2009 at 3:22 AM, Hussein B hubaghd...@gmail.com wrote: Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime start = datetime.now() print start

Re: What is wrong in my list comprehension?

2009-02-01 Thread Peter Otten
Hussein B wrote: Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime start = datetime.now() print start lines = [line for line in

What is wrong in my list comprehension?

2009-02-01 Thread Hussein B
Hey, I have a log file that doesn't contain the word Haskell at all, I'm just trying to do a little performance comparison: ++ from datetime import time, timedelta, datetime start = datetime.now() print start lines = [line for line in file('/media/sda4/Servers/Apache/