func? just prints func.__doc__, nothing magic.<br><br>There's a simple, standard-library way to make wrapper functions: functools.wraps<br><a href="http://docs.python.org/library/functools.html#functools.wraps">http://docs.python.org/library/functools.html#functools.wraps</a><br>
<br clear="all">-Ken<br>
<br><br><div class="gmail_quote">On Tue, Jan 5, 2010 at 2:08 AM, Brent Pedersen <span dir="ltr"><<a href="mailto:bpederse@gmail.com">bpederse@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Mon, Jan 4, 2010 at 10:53 PM, Tsviki Hirsh <<a href="mailto:tsviki.hirsh@gmail.com">tsviki.hirsh@gmail.com</a>> wrote:<br>
> Dear list,<br>
> The magic ? and ?? commands are among the most useful features in ipython<br>
> (at least for me),<br>
> I'm also using them to read my selfdocumentation on my own functions.<br>
> Therefore I was surprised to learn that you cannot read the doc string of a<br>
> decorated function using ? or ??<br>
> for example, consider this decorator and function<br>
><br>
> def deco(f):<br>
> '''decorator docstring'''<br>
> def _deco(*args,**kwargs):<br>
> '''decorator inner function docstring'''<br>
> print 'args=',args<br>
> return f(*args,**kwargs)<br>
> return _deco<br>
> @deco<br>
> def myfunc(x,y):<br>
> '''function docstring'''<br>
> return x+y<br>
><br>
> if I try to call myfunc docstring using ? I get:<br>
><br>
> In [18]: exem.myfunc?<br>
> Type: function<br>
> Base Class: <type 'function'><br>
> String Form: <function _deco at 0x868a5a4><br>
> Namespace: Interactive<br>
> File: /home/tsviki/exem.py<br>
> Definition: exem.myfunc(*args, **kwargs)<br>
> Docstring:<br>
> decorator inner function docstring<br>
><br>
> and if I try to call ??, it just gives me the decorator inner function.<br>
> Is there a way to overlap this?<br>
> linking the decorator __doc__ to myfunc.__doc__ won't help in case that I<br>
> have several functions that use the same decorator.<br>
> Any help?<br>
<br>
</div></div>hi,<br>
decorate your decorator :)<br>
<a href="http://pypi.python.org/pypi/decorator" target="_blank">http://pypi.python.org/pypi/decorator</a><br>
<br>
i think something like:<br>
<br>
from decorator import decorator<br>
<br>
@decorator<br>
<div class="im">def deco(f):<br>
'''decorator docstring'''<br>
</div> @decorator<br>
<div class="im"> def _deco(*args,**kwargs):<br>
'''decorator inner function docstring'''<br>
print 'args=',args<br>
return f(*args,**kwargs)<br>
return _deco<br>
<br>
<br>
<br>
<br>
</div><div class="im">> Thanks a lot<br>
> Tsviki Hirsh<br>
><br>
</div>> _______________________________________________<br>
> IPython-user mailing list<br>
> <a href="mailto:IPython-user@scipy.org">IPython-user@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
><br>
><br>
_______________________________________________<br>
IPython-user mailing list<br>
<a href="mailto:IPython-user@scipy.org">IPython-user@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
</blockquote></div><br>