Hi Gael, On Thu, Aug 13, 2009 at 10:24 AM, Gael Varoquaux<gael.varoqu...@normalesup.org> wrote: > On Thu, Aug 13, 2009 at 10:12:23AM -0400, Darren Dale wrote: >> I appreciate how much time has gone into the patch, but this impacts >> so much code I think it is important to really nail the >> implementation. I think everything should be rolled up into a single >> high level decorator if possible. I offered a suggestion in the >> tracker. Consider: > >> with_doc(*args, **kwargs): >> mod_doc(f): >> if args: >> if not isinstance(args[0], str): >> # inherit docstring from first argument >> inherit = args.pop(0).__doc__ >> if f.__doc__ is None: >> f.__doc__ = inherit >> else: >> f.__doc__ = inherit + '\n\n' + f.__doc__ >> if kwargs: >> # mapping interpolation >> f.__doc__ = f.__doc__ % kwargs >> if args: >> try: >> # inserting >> f.__doc__ = f.__doc__ % args >> except TypeError: >> # appending >> if f.__doc__ is None: >> f.__doc__ = '' >> f.__doc__ = f.__doc__ + '\n\n'+ '\n\n'.join(args) >> return f >> return mod_doc > > I have not followed the conversation, so please forgive me if I am > talking bull**, but why are you not using functools.wraps? I have found > it is useful to make really sure that you are keeping all the > properties of a function that you want to decorate.
I am aware of functools.wraps and have used it myself. So far we are only modifying and returning the original function, not a wrapped version of the original, so functools.wraps is not necessary. Darren ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel