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 when I run in non-debug mode. I could do something
> like this, using a simple trace example.
def decorator(func):
if __debug__:
@functools.wraps(func)
def inner(*args, **kwargs):
preprocess()
result = func(*args, **kwargs)
postprocess()
return result
return inner
else:
return func
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list