[Python-Dev] PEP-317

Pat Miller patmiller@llnl.gov
Mon, 09 Jun 2003 08:03:17 -0700


> Well, I was still casually using string exceptions up until about a year
>> ago, and I think I'm not the only one.  There's probably lots of pre-2.0
>> code still running in the wild with string exceptions.
> 
> Note "casually", probably in throw-away code.  If you knew they didn't
> exist, you'd "casually" use some built-in exception, e.g. RuntimeError.

I'm mostly with Guido on this however...  I would venture that many of
these "wild" string raises are shortcut error messages.  Is there really
a lot of code that does < try:  catch "foo": > ?

I still "casually" use string exceptions mostly as a shortcut to get
unfinished code to bomb (or to generate a quick traceback.  Often of the form

if foo.is_simple():
    foo.easy()
else:
    raise 'zz'


Granted, I could probably use

raise NotImplementedError

But that is more typing than I want for a quick line that will likely
be ripped out the first time it actually triggers.

Also, I sometimes trap NotImplementedError, so I want an exception that
I would never try to catch (I don't think I could stomach a except "zz":
line in my code :-).

The good news for me (and I suspect many other casual string throwers)
is that if < raise "zz" > raises ANY runtime exception, most of my
code will continue to "do the right thing."

Pat

-- 
Patrick Miller | (925) 423-0309 | http://www.llnl.gov/CASC/people/pmiller

Be the change you want to see in the world.
  -- Mahatma Gandhi (1869-1948)