Hi
Consider:
def fn(a, b, c): pass
fn.__wibble__ = 123
fn.__wibble__ # Give 123, of course.
Now consider:
@wibble
def fn(a, b, c=None):
'''Usual docstring goes here.'''
if c is None: c = []
'#wibble'
return c.extend([a, b])
The @wibble decorator sets fn.__wibble__ to point to the end of the line just before '#wibble'.
We can now define Help(fn) to produce something like:
fn(a, b, c=None)
Usual docstring goes here. --
if c is None: c = []
There we go. The functionality asked for, in a way that works with existing Python. If nothing else, we can use this for experiments to explore the idea. Often in Python there are functions whose source is self-explanatory.
Example:
@wibble
def fahr_to_cent(fahr):
return (fahr - 32) * 5 /9
'#wibble'
And now for Help(fahr_to_cent) we get:
fahr_to_cent(fahr)
--
return (fahr - 32) * 5 /9
Final word. Does anyone use PEP 232, function attributes? If not, perhaps remove it as a waste of space.
with kind regards
Jonathan