Paul Rubin wrote: > Hallvard B Furuseth <[EMAIL PROTECTED]> writes: >> > class NeverRaised(Exception): pass >> > for ex in ZeroDivisionError, NeverRaised: >> >> Heh. Simple enough. Unless some obstinate person raises it anyway... > > Hmm, ok, how's this?: > > def NeverRaised(): > class blorp(Exception): pass > return blorp > for ex in ZeroDivisionError, NeverRaised(): > ...
Or you can create an unraisable exception: >>> \ class NeverRaised(Exception): def __init__(self, *args): raise RuntimeError('NeverRaised should never be raised') >>> \ try: raise NeverRaised except NeverRaised: print "caught it" Traceback (most recent call last): File "<pyshell#47>", line 4, in __init__ raise RuntimeError('NeverRaised should never be raised') RuntimeError: NeverRaised should never be raised -- http://mail.python.org/mailman/listinfo/python-list