Joe
Joe

Reputation: 3089

python - nested try/except question

try:
    for i in list:
        try:
            #python code...
        except Exception,e:
            #error handler
except Exception, e:
    #error handler

If in the nested try/except it errors out, does the loop continue running?

Upvotes: 0

Views: 3784

Answers (2)

Tudor
Tudor

Reputation: 4164

Aside from the typo for "cexcept" in the inner except, the loop should continue. Actually, the parent try/except can not be broken only by that for, but I'm sure this is just a simple example of the actual code.

Upvotes: 1

JesperE
JesperE

Reputation: 64404

Yes, it does, since you caught the exception. Although if you just have a comment there and not a real line of code, I think Python may complain. (I haven't written Python code in a while.)

Upvotes: 2

Related Questions