howto redirect and extend help content ?

S

Stef Mientki

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
"""
# 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 ?


thanks,
Stef Mientki
 
R

Rob Wolfe

Stef Mientki said:
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
"""

# 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:
.... """The M-point triangular window.
.... """
.... return "triang"
.... Help on function triang in module __main__:

triang(M, sym=1)
The M-point triangular window.
.... def wrap(g):
.... g.__doc__="chunked version of %s\n%s" % (f.__name__,f.__doc__)
.... return g
.... return wrap
.... .... def chunked_triang(M):
.... return "chunked triang"
.... Help on function chunked_triang in module __main__:

chunked_triang(M)
chunked version of triang
The M-point triangular window.
 
S

Stargaming

Stef said:
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
"""

# 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 ?


thanks,
Stef Mientki

Don't you think your users can follow this easy reference theirselves?
 
S

Stef Mientki

I'm making special versions of existing functions,
Don't you think your users can follow this easy reference theirselves?
My public consist of physicians with some knowledge of MatLab.
I'm trying to give them a system (based on Python) for which no knowledge of Python is needed.
When they put the cursor on the name of a function (in some pre-processing language, preferably
something like LabView), the help text will be shown automatically in a separate window,
without typing any commands.

cheers,
Stef Mientki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top