Re: try: except never:

2006-01-13 Thread Hallvard B Furuseth
Thanks for the help. Tom Anderson writes: class NeverRaised(Exception): def __init__(self, *args): raise RuntimeError('NeverRaised should never be raised') Briliant! Although i'd be tempted to define an UnraisableExceptionError to signal what's happened. Or ... A package we are

Re: try: except never:

2006-01-11 Thread Duncan Booth
Tom Anderson wrote: class NeverRaised(Exception): def __init__(self, *args): raise RuntimeError('NeverRaised should never be raised') Briliant! Although i'd be tempted to define an UnraisableExceptionError to signal what's happened. Or ... class ImpossibleException(Exception):

try: except never:

2006-01-10 Thread 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

Re: try: except never:

2006-01-10 Thread Paul Rubin
Hallvard B Furuseth [EMAIL PROTECTED] writes: '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. class NeverRaised(Exception): pass for ex in

Re: try: except never:

2006-01-10 Thread Hallvard B Furuseth
Paul Rubin writes: Hallvard B Furuseth [EMAIL PROTECTED] writes: '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. class NeverRaised(Exception):

Re: try: except never:

2006-01-10 Thread Paul Rubin
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

Re: try: except never:

2006-01-10 Thread Duncan Booth
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

Re: try: except never:

2006-01-10 Thread Tom Anderson
On Tue, 10 Jan 2006, Duncan Booth wrote: 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