[IPython-dev] Two basic Notebook questions (Python focus)

Thomas Kluyver takowl at gmail.com
Fri Jan 30 18:48:59 EST 2015

On 30 January 2015 at 15:26, Jean Bigboute <jeanbigboute at gmail.com> wrote:

> b) Is it possible to pass arguments to a magic function?
> e.g.
> import inspect
> print inspect.getsource(function)

This is probably easiest to do in a plain Python function. Create a file
~/.ipython/profile_default/startup/printsource.py (which IPython will
automatically run when it starts, and put in it:

import inspect
def source(func)
    print inspect.getsource(function)

Now you can just type 'source(f)' to see a function in your notebook. Be
aware, though, that if you share that notebook, other people won't have the
source() function defined. You could also define it at the top of the
notebook if you prefer.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150130/abd3b6cb/attachment.html>

More information about the IPython-dev mailing list