code of a function

alex23 wuwei23 at gmail.com
Thu May 29 19:20:49 EDT 2008


On May 30, 8:54 am, Alan Isaac <ais... at american.edu> wrote:
> Anand Patil wrote:
> > If you're using IPython, you can do svd?? .
>
> http://www.scipy.org/doc/numpy_api_docs/numpy.linalg.linalg.html
>
> hth,
> Alan Isaac

That wasn't a question :) In IPython, '<entity>?' is roughly
equivalent to 'help(<entity>)', whereas '<entity>??' displays the
code, if possible:

IPython 0.8.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints
more.

In [1]: from functools import wraps

In [2]: wraps??
Type:           function
Base Class:     <type 'function'>
String Form:    <function wraps at 0x00CF31B0>
Namespace:      Interactive
File:           c:\python25\lib\functools.py
Definition:     wraps(wrapped, assigned=('__module__', '__name__',
'__doc__'), updated=('__dict__',))
Source:
def wraps(wrapped,
          assigned = WRAPPER_ASSIGNMENTS,
          updated = WRAPPER_UPDATES):
    """Decorator factory to apply update_wrapper() to a wrapper
function

       Returns a decorator that invokes update_wrapper() with the
decorated
       function as the wrapper argument and the arguments to wraps()
as the
       remaining arguments. Default arguments are as for
update_wrapper().
       This is a convenience function to simplify applying partial()
to
       update_wrapper().
    """
    return partial(update_wrapper, wrapped=wrapped,
                   assigned=assigned, updated=updated)

Which is very handy, like most of IPython.



More information about the Python-list mailing list