H
Hallvard B Furuseth
I'd like an 'except <exception which is never raised>' statement
Is there a defined way to do that, for Python 2.2 and above?
'except None:' works for now, but I don't know if that's safe:
for ex in ZeroDivisionError, None:
try:
1/0
except ex:
print "Ignored first exception."
I could just use
except ZeroDivisionError:
if not <first iteration>:
raise
print "Ignored first exception."
but the variant above gets a bit neater.
Is there a defined way to do that, for Python 2.2 and above?
'except None:' works for now, but I don't know if that's safe:
for ex in ZeroDivisionError, None:
try:
1/0
except ex:
print "Ignored first exception."
I could just use
except ZeroDivisionError:
if not <first iteration>:
raise
print "Ignored first exception."
but the variant above gets a bit neater.