RELEASED Python 2.4, alpha 2

David Eppstein eppstein at ics.uci.edu
Thu Aug 5 13:35:22 EDT 2004


In article <Pine.LNX.4.44.0408051258000.10473-100000 at ccc6.wpi.edu>,
 Christopher T King <squirrel at WPI.EDU> wrote:

> On Fri, 6 Aug 2004, Anthony Baxter wrote:
> 
> > On Thu, 5 Aug 2004 12:29:51 -0400, Christopher T King <squirrel at wpi.edu> 
> > wrote:
> > > What does one do if a decorator raises an exception?  
> > 
> > def deco(func):
> >       raise TypeError
> > 
> > @deco
> > def foo():
> >     print "hello"
> 
> Yes yes yes, I /know/ they are /able/ to raise exceptions.  My point was 
> about handling them in a clean, concise way.

What do you do if any other piece of code raises an exception?
Why do you think decorators should be any different?

If this is an actual possibility, there's nothing preventing you from 
wrapping a decorated def inside a try-except block.

-- 
David Eppstein
Computer Science Dept., Univ. of California, Irvine
http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list