<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi all,<br><br></div>Is there a sane way to know if some code is executing in a rich display environment like the qtconsole or the notebook?<br><br></div>I think the following could work:<br><br></div><span style="font-family:monospace,monospace">try:<br></span></div><span style="font-family:monospace,monospace">    from ipykernel.zmqshell import ZMQInteractiveShell<br></span></div><div><span style="font-family:monospace,monospace">    ip = get_ipython()<br></span></div><span style="font-family:monospace,monospace">    rich_display = isinstance(ip, ZMQInteractiveShell)<br></span></div><span style="font-family:monospace,monospace">except:<br></span></div><span style="font-family:monospace,monospace">    rich_display = False</span><br><br></div>Thanks!!<br><br></div>Best.<br></div>