Stef Mientki <[EMAIL PROTECTED]> writes: > I'm making special versions of existing functions, > and now I want the help-text of the newly created function to exists of > 1. an extra line from my new function > 2. all the help text from the old function > > # the old function > def triang(M,sym=1): > """The M-point triangular window. <== old help text > """ > .... > > # the new function > def chunked_triang(M): > """ Chunked version of "triang" <== the extra line > """ > > >>> help(chunked_triang) > # should give something like > > chunked_triang(M) <== the new definition > Chunked version of "triang" <== the extra line > The M-point triangular window. <== old help text > > Is that possible ?
You can take advantage of the decorator syntax: >>> def triang(M,sym=1): ... """The M-point triangular window. ... """ ... return "triang" ... >>> help(triang) Help on function triang in module __main__: triang(M, sym=1) The M-point triangular window. >>> def add_doc(f): ... def wrap(g): ... g.__doc__="chunked version of %s\n%s" % (f.__name__,f.__doc__) ... return g ... return wrap ... >>> @add_doc(triang) ... def chunked_triang(M): ... return "chunked triang" ... >>> help(chunked_triang) Help on function chunked_triang in module __main__: chunked_triang(M) chunked version of triang The M-point triangular window. -- HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list