2006/9/21, Berthold Höllmann <[EMAIL PROTECTED]>: > Saving the following code to a file and running the code through > python does not give the expected error. disableling the "@decor" line > leads to the expected error message. Is this a bug or an overseen > feature?
Try the new_decor class described below: >>> class decor(object): ... def __init__(self, f): ... self.f = f ... def __call__(self, *args, **kw): ... return self.f(*args, **kw) ... >>> class new_decor(object): ... def __init__(self, f): ... self.f = f ... self.__doc__ = f.__doc__ ... self.__name__ = f.__name__ ... def __call__(self, *args, **kw): ... return self.f(*args, **kw) ... >>> def f(a, b): ... ''' ... >>> f(1, 2) ... False ... >>> f(2, 2) ... False ... ''' ... return a == b ... >>> f.__doc__ '\n\t>>> f(1, 2)\n\tFalse\n\t>>> f(2, 2)\n\tFalse\n\t' >>> decor(f).__doc__ == f.__doc__ False >>> new_decor(f).__doc__ == f.__doc__ True -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list