> I'm trying to get only the lines that start with
> "This" for a text file.
> 
> Here's what I wrote:
> 
> >>> import re
> >>> f = open('c:/lines.txt').readlines()
> >>> for line in f:
> match = re.search('^This',f)
> if line == match:
> print match

try 

     if line.startwith('This'):

its easier!
But your problem above is that match returns a match object 
which is not a string. So you can't compare directly you 
need to extract the string from inside the match object!

HTH

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to