reading a line in file

Brian McCann Brian.McCann at
Mon Aug 20 21:54:07 CEST 2007

Shawn, Tim ,Jay
many thanks,
It looks like there are many ways this problem can be approached

either by using  regex or a tokens 

Tim I'm not familiar with your solution, but will learn about that method also
Jay, what do you mean by regex comes with a lot of overhead?



From: at on behalf of Shawn Milochik
Sent: Mon 8/20/2007 3:07 PM
To: python-list at
Subject: Re: reading a line in file

Hopefully this will help (using your input file)

#!/usr/bin/env python
import re
buildinfo = "input.txt"
input = open(buildinfo, 'r')

regex = re.compile(r"^\s*build.number=(\d+)\s*$")

for line in input:
    if, line):
        print line
        buildNum = re.sub(r"^\s*build.number=(\d+)\s*$", "\\1", line)
        print line
        print buildNum

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list