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: Fredrik Lundh <fredrik@pythonware.com>
Date: Thu Oct 06 2005 - 21:31:19 CEST

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

or

    def debugdecorator(func):
        if __debug__:
            ...
        else:
            return func

etc.

</F>
Received on Sat Oct 15 04:14:00 2005