Issue
So I understand on a surface level how to render html, using the display function:
IPython.display.HTML('<b>FOOBAR</b>')
But what if I want to create a generic function to dynamically render html (i.e how do I make display work in a function.) For instance:
def foo():
IPython.display.HTML('<b>FOOBAR</b>')
foo() # Does not render anything :(
Solution
IPython.display.HTML
only creates a display object. It doesn't display it. Such objects are only auto-displayed if the last statement of a cell is an expression statement with such an object as the expression's value.
In any other context, you need to call IPython.display.display
to display the object:
def foo():
IPython.display.display(IPython.display.HTML('<b>FOOBAR</b>'))
Answered By - user2357112 supports Monica
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.