"no variable or argument declarations are necessary."

Fredrik Lundh fredrik at pythonware.com
Thu Oct 6 15:31:19 EDT 2005


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> 






More information about the Python-list mailing list