I’m brand new to python, and need some help understanding this code fragment:
for c in [B, C, D]:
try:
raise c()
except D:
print "D"
except C:
print "C"
except B:
print "B"
Reading python docs, it seems raise() throws an exception, but I can’t figure out why raise() is within the try block. Shouldn’t it be something like this:
try:
//do something
catch:
raise()
raiseis how you raise exceptions in the first place. A loneraisein an exception handler only propagates the exception to external handlers.