[IPython-user] docstring of decorated functions
Tsviki Hirsh
tsviki.hirsh@gmail....
Tue Jan 5 00:53:31 CST 2010
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
@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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20100105/5d1e5a2b/attachment.html
More information about the IPython-user
mailing list