Re: decorators only when __debug__ == True

2010-04-01 Thread MRAB
Steven D'Aprano wrote: On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but your wording is funny and could

Re: decorators only when __debug__ == True

2010-04-01 Thread Steve Holden
MRAB wrote: Steven D'Aprano wrote: On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but your wording is funny

Re: decorators only when __debug__ == True

2010-04-01 Thread Steve Howell
On Apr 1, 6:16 am, Steve Holden st...@holdenweb.com wrote: MRAB wrote: I had the following idea: define the terms 'decorator', 'decoration' and 'decoratee'. The decorator applies the decoration to the decoratee. The decoratee is the function defined locally in the decorator. It would

Re: decorators only when __debug__ == True

2010-04-01 Thread MRAB
Steve Holden wrote: MRAB wrote: Steven D'Aprano wrote: On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but

Re: decorators only when __debug__ == True

2010-03-31 Thread LX
On Mar 30, 2:41 pm, MRAB pyt...@mrabarnett.plus.com wrote: LX wrote: On Mar 29, 6:34 pm, MRAB pyt...@mrabarnett.plus.com 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

Re: decorators only when __debug__ == True

2010-03-31 Thread MRAB
LX wrote: On Mar 30, 2:41 pm, MRAB pyt...@mrabarnett.plus.com wrote: LX wrote: On Mar 29, 6:34 pm, MRAB pyt...@mrabarnett.plus.com 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

Re: decorators only when __debug__ == True

2010-03-31 Thread Stephen Hansen
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 that during runtime, with a breakpoint in some arbitrary main() in main.py, I get something similar to the following

Re: decorators only when __debug__ == True

2010-03-31 Thread Steven D'Aprano
On Wed, 31 Mar 2010 22:27:05 +0100, MRAB wrote: LX wrote: [...] It looks to me the call stack still includes the additional level of the decorator... what am I missing? Thank you for your time. Are you still defining your decorators in the same way as in your original post? A decorator

Re: decorators only when __debug__ == True

2010-03-31 Thread MRAB
Steven D'Aprano wrote: On Wed, 31 Mar 2010 22:27:05 +0100, MRAB wrote: LX wrote: [...] It looks to me the call stack still includes the additional level of the decorator... what am I missing? Thank you for your time. Are you still defining your decorators in the same way as in your original

Re: decorators only when __debug__ == True

2010-03-31 Thread LX
On Mar 31, 2:28 pm, Stephen Hansen apt.shan...@gmail.invalid 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 that during runtime, with a breakpoint in

Re: decorators only when __debug__ == True

2010-03-31 Thread Steven D'Aprano
On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but your wording is funny and could confuse the OP.

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 6:34 pm, MRAB pyt...@mrabarnett.plus.com 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 something like

Re: decorators only when __debug__ == True

2010-03-30 Thread LX
On Mar 29, 7:11 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au 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 MRAB
LX wrote: On Mar 29, 6:34 pm, MRAB pyt...@mrabarnett.plus.com 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 something

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,

Re: decorators only when __debug__ == True

2010-03-29 Thread MRAB
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 something like this, using a simple trace example. @decorator def