Re: Using StopIteration

2006-05-08 Thread tkpmep
This is just what the doctor ordered. Thanks, as always, everyone! > By breaking out of the while loop as shown above. > > Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Using StopIteration

2006-05-08 Thread vbgunz
to catch and recover from StopIterations, use this: try: raise StopIteration except StopIteration: print 'caught StopIteration!' # verbose: sys.exc_info() requires import sys -- http://mail.python.org/mailman/listinfo/python-list

Re: Using StopIteration

2006-05-08 Thread vbgunz
sequence = ['','2'] for index, line in enumerate(sequence): if line.isspace():continue if line[:1].isdigit(): print 'index %s: starts with digit %s' % (index, line[:1]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Using StopIteration

2006-05-08 Thread Steve R. Hastings
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:

Re: Using StopIteration

2006-05-08 Thread Peter Otten
[EMAIL PROTECTED] 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) > > filenames=glob.glob("C:/*.txt") > for fn in filenames: f = open(fn) for line in f: if

Using StopIteration

2006-05-08 Thread tkpmep
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) filenames=glob.glob("C:/*.txt") for fn in filenames: f =file(fn) line = " " while line[0] not in digits: line = f.next()