Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython _repr_html_

I really like how in the IPython Notebook you can add a class method called _repr_html_() to print a rich HTML version of your class.

Is there a way to explicitly force this output, say if I want to print 2 objects out at the same time?

print obj1, obj2

Below is solved, but I would still like to know if the above is possible since writing a wrapper is tad tedious

Or, if I have a wrapper class for many of these objects and I want to nest their HTML representation inside the wrapper representation?

def _repr_html_(self):
    return '<td>%s</td><td></td>' % (self.obj1, self.obj2)
like image 778
dvreed77 Avatar asked Dec 14 '22 18:12

dvreed77


1 Answers

Use from IPython.display import display and call display on each or your objects.

like image 85
Matt Avatar answered Jan 01 '23 16:01

Matt