[Zope3-dev] Re: Deprecate conditionally

Philipp von Weitershausen philipp at weitershausen.de
Mon Mar 27 13:37:38 EST 2006


Florian Lindner wrote:
> Hello,
> I want show a deprecation warning only if a argument of a function is set to 
> False.
> 
> def foo(arg1, arg2, arg3 = False):
> 
>     if not arg3:
>         arg3 = deprecation.deprecated(arg3, "arg3=False is deprecated.")
> 
> But that does not show anything. How do it correctly?

Just emit a warning::

import warnings
def foo(arg1, arg2, arg3=False):
    if not arg3:
        warnings.warn("arg3=False is deprecated", DeprecationWarning, 2)

Philipp


More information about the Zope3-dev mailing list