On Nov 1, 7:35 pm, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka <miki.teb...@gmail.com> wrote: > > In my box, there are some spaces (tabs?) before "Speed". IMO > > re.search("Speed", line) will be a more robust. > > Or simply: > > if "Speed" in line: > > There is no need for a regular expression here. This would also work > and be a bit more discriminating: > > if line.strip().startswith("Speed") > > BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot > match, since line[0:6] is a 6-character slice, while "Speed" is a > 5-character string. > > Cheers, > Ian
Ian, Replacing my regular expression with line.strip().startswith did the trick. Thanks for the tip! Paul -- http://mail.python.org/mailman/listinfo/python-list