Re: decorators only when __debug__ == True

2010-03-31 Thread LX
On Mar 31, 2:28 pm, Stephen Hansen wrote: > On 2010-03-31 13:59:01 -0700, LX said: > > > > > > >> pass_decorator will be called when the decorated function is _defined_, > >> but not when the decorated function is _called_. > > > Why is it then t

Re: decorators only when __debug__ == True

2010-03-31 Thread LX
On Mar 30, 2:41 pm, MRAB wrote: > LX wrote: > > On Mar 29, 6:34 pm, MRAB wrote: > >> LX wrote: > >>> Hi all, I have a question about decorators. I would like to use them > >>> for argument checking, and pre/post conditions. However, I don't want

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 7:11 pm, Steven D'Aprano wrote: > On Mon, 29 Mar 2010 17:54:26 -0700, LX wrote: > > Hi all, I have a question about decorators. I would like to use them for > > argument checking, and pre/post conditions. However, I don't want the > > additional overhead

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 6:34 pm, MRAB wrote: > LX wrote: > > Hi all, I have a question about decorators. I would like to use them > > for argument checking, and pre/post conditions. However, I don't want > > the additional overhead when I run in non-debug mode. I could do > &

decorators only when __debug__ == True

2010-03-29 Thread LX
Hi all, I have a question about decorators. I would like to use them for argument checking, and pre/post conditions. However, I don't want the additional overhead when I run in non-debug mode. I could do something like this, using a simple trace example. @decorator def pass_decorator(f, *args, **

AssertionError not caught?

2009-02-01 Thread LX
This one has me mystified good! This works (print statement is executed as the Exception is caught) as advertised: try: raise AssertionError except AssertionError: print "caught AssertionError" But this one does not: def test(): raise AssertionError try: