[Python-Dev] Another traceback idea [was: except Exception as err, tb]

dustin at v.igoro.us dustin at v.igoro.us
Fri Mar 2 23:50:46 CET 2007


On Sat, Mar 03, 2007 at 11:00:53AM +1300, Greg Ewing wrote:
> Now, I'm not proposing that the raise statement should
> actually have the above syntax -- that really would be
> a step backwards. Instead it would be required to have
> one of the following forms:
> 
>     raise ExceptionClass
> 
> or
> 
>     raise ExceptionClass(args)

Eep, that's awkward.  If you are using exceptions for flow control, why
would you use the second form?  

Why not just allow both exception classes and exception instances to be
raised, and only instantiate-at-catch in the case of a raise of a class
and a catch with an "as" clause?  Then the auto-instantiation becomes a
"convenience" feature of catch, safely relegating it to an
easily-understood and easily-ignored corner of the user's
conceptualization of exception handling.

The above also looks a lot like the current syntax, but (unless I'm
mistaken) ExceptionClass will be instantiated immediately right now.  It
seems best not to change the semantics of existing syntax if not
necessary.

I've been snoozing though this conversation until now, so if I've spoken
out of turn, please forgive me.

Dustin


More information about the Python-Dev mailing list