Resuming in exception handling

Alex Martelli aleaxit at yahoo.com
Tue Apr 17 06:39:22 EDT 2001


"Lucas Vogel" <lucas7 at home.com> wrote in message
news:kwOC6.9726$181.2051642 at news1.rdc1.az.home.com...
    [snip]

General resumption is rather unfeasible, but your specific
case is not all that hard.  Moving the try/except within
the loop is the key to the solution here:


flist = glob.glob(LWPath + '\\LW*.txt')
for fname in flist:
    try:
        os.remove(fname)
    except OSError:
        print "skipping", fname
    else:
        print "removed", fname


Alex






More information about the Python-list mailing list