Re: "no variable or argument declarations are necessary."
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: "no variable or argument declarations are necessary."

From: Steve Holden <steve@holdenweb.com>
Date: Thu Oct 06 2005 - 22:56:30 CEST

Ron Adam wrote:
> Fredrik Lundh wrote:
>
>
>>Ron Adam wrote:
>>
>>
>>
>>>Is there a way to conditionally decorate? For example if __debug__ is
>>>True, but not if it's False? I think I've asked this question before. (?)
>>
>>
>>the decorator is a callable, so you can simply do, say
>>
>> from somewhere import debugdecorator
>>
>> if not __debug__:
>> debugdecorator = lambda x: x
>
>
> Ah... thanks.
>
> I suppose after(if) lambda is removed it would need to be.
>
> def nulldecorator(f):
> return f
>
> if not __debug__:
> debugdecorator = nulldecorator
>
It would be easier to write

     if not __debug__:
         def debugdecorator(f):
             return f

regards
  Steve

-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/
Received on Sat Oct 15 04:14:18 2005