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
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
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
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:
[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
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()