Using StopIteration

Steve R. Hastings steve at hastings.org
Mon May 8 14:50:05 EDT 2006


On Mon, 08 May 2006 11:23:28 -0700, tkpmep wrote:
> I create list of files, open each file in turn, skip past all the blank
> lines, and then process the first line that starts with a number (see
> code below)


Here is what I suggest for you:


filenames=glob.glob("C:/*.txt")
for fn in filenames:
    for line in open(fn):
        if line[0] in digits:
            ProcessLine(line)
            break


-- 
Steve R. Hastings    "Vita est"
steve at hastings.org    http://www.blarg.net/~steveha




More information about the Python-list mailing list