try: except <never>:

Hallvard B Furuseth h.b.furuseth at
Tue Jan 10 07:53:21 EST 2006

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:
        except ex:
            print "Ignored first exception."

I could just use
        except ZeroDivisionError:
            if not <first iteration>:
            print "Ignored first exception."
but the variant above gets a bit neater.


More information about the Python-list mailing list