[IPython-dev] Display Function from with in a Function

Cyrille Rossant cyrille.rossant at gmail.com
Wed Jan 28 10:17:11 EST 2015


HTML(...) will only display something if it's the last statement of a
code cell. This is because IPython always displays the result of the
last result of a cell (unless you terminate the line with a semicolon
';').

A more reliable way of displaying stuff is to use display() or
display_html(). This will work from within functions. See
http://ipython.org/ipython-doc/dev/api/generated/IPython.display.html
for more details.

2015-01-28 16:08 GMT+01:00 John Omernik <john at omernik.com>:
> Greetings all, I am using iPython notebook, I can do this:
>
> from IPython.display import display, HTML
>
> h = "<H1>Oh My </H1>"
> HTML(h)
>
> and get the expected result
>
> But if I do this:
>
> from IPython.display import display, HTML
>
> def runme(html):
>     HTML(html)
>
>
> h = "<H1>Oh My </H1>
> runme(h)
>
> I get no results.
>
> I've noticed this is true for other displays as well, how can I add
> displays from withi functions?
>
> Thanks!
>
> John
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



More information about the IPython-dev mailing list