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/ -- http://mail.python.org/mailman/listinfo/python-list