5 Jan 07:53
docstring of decorated functions
Tsviki Hirsh <tsviki.hirsh <at> gmail.com>
2010-01-05 06:53:31 GMT
2010-01-05 06:53:31 GMT
Dear list,
The magic ? and ?? commands are among the most useful features in ipython (at least for me),
I'm also using them to read my selfdocumentation on my own functions.
Therefore I was surprised to learn that you cannot read the doc string of a decorated function using ? or ??
for example, consider this decorator and function
def deco(f):
'''decorator docstring'''
def _deco(*args,**kwargs):
'''decorator inner function docstring'''
print 'args=',args
return f(*args,**kwargs)
return _deco
<at> deco
def myfunc(x,y):
'''function docstring'''
return x+y
if I try to call myfunc docstring using ? I get:
In [18]: exem.myfunc?
Type: function
Base Class: <type 'function'>
String Form: <function _deco at 0x868a5a4>
Namespace: Interactive
File: /home/tsviki/exem.py
Definition: exem.myfunc(*args, **kwargs)
Docstring:
decorator inner function docstring
and if I try to call ??, it just gives me the decorator inner function.
Is there a way to overlap this?
linking the decorator __doc__ to myfunc.__doc__ won't help in case that I have several functions that use the same decorator.
Any help?
Thanks a lot
Tsviki Hirsh
_______________________________________________ IPython-user mailing list IPython-user <at> scipy.org http://mail.scipy.org/mailman/listinfo/ipython-user
RSS Feed