How to determine if ipton qtconsole is working?

IPython laptop and Qt console support displaying rich representations of objects. This is done by defining, for example, a method _repr_html_.

The problem is that the two render HTML differently. Is there a way to determine if it works under ipython qtconsole, so that I can use a more basic set of HTML? Preferably a documented method that is unlikely to happen in the future?

+4
source share
1 answer

I have a similar problem. Performing color in an IPython terminal requires a call to the Windows DLL, but the color in qtconsole seems to support Linux-based escape sequences ... anyway. here is what i found. Its ugly ... but at least it will tell you the terminal against qtconsole ... Oh, and I have not tried with a laptop:

import __main__
if hasattr(__main__,"get_ipython"): 
   import IPython.kernel.zmq.zmqshell as z
   if isinstance(get_ipython(), z.ZMQInteractiveShell):
       print 'yep...its qtconsole'
0
source

Source: https://habr.com/ru/post/1538491/


All Articles