John Machin wrote:
[snip]
> 2. Then realise that your test is equivalent to
>
> if not line.startswith('^From '):
Whoops!
That '^From ' (and all later ones) should have been 'From '
(the perils of over-hasty copy/paste)
The timings are, if anything, a tiny bit faster than before.
Cheers,
John
wo_shi_big_stomach wrote:
> Thanks for the great tip about fileinput.input(), and thanks to all who
> answered my query. I've pasted the working code below.
>
[snip]
> # check first line only
> elif fileinput.isfirstline():
> if not re.search('^From ',line):
This "works"