[IPython-dev] Best way to detect IPython notebook

Jason Moore moorepants@gmail....
Thu Feb 20 21:56:41 CST 2014


Tarun's has some code that starts a SimpleHTTPServer which runs a three.js
app on a new port. He's been trying to have the code open a new browser tab
if you run the code from the notebook. See the last cell here:
http://nbviewer.ipython.org/github/PythonDynamics/pydy-tutorial-pycon-2014/blob/master/notebooks/n08_visualization.ipynb(once
IPython 2.0 is out, we plan to have this optionally open up in a
notebook cell). The code that does this is mostly here:
https://github.com/pydy/pydy-viz/blob/master/pydy_viz/server.py

I think he was trying to detect whether you were in a notebook so that
different behavior happens when the visualization server is opened. He'll
have to comment more on the details.


Jason
moorepants.info
+01 530-601-9791


On Thu, Feb 20, 2014 at 2:41 PM, Thomas Kluyver <takowl@gmail.com> wrote:

> On 20 February 2014 08:45, TARUN GABA <tarun.gaba7@gmail.com> wrote:
>
>>     if get_ipython().config['KernelApp']['parent_appname'] ==
>> 'ipython-notebook':
>>
>
> Be aware that:
> - This only tells you what started the kernel - you can start a kernel
> with the notebook and attach a Qt console to it, and there's no good way to
> tell which one has sent a piece of code.
> - We want to get rid of that value eventually:
> https://github.com/ipython/ipython/pull/4980
>
> As Matthias mentioned, can you tell us a bit more about what it is that
> you're trying to do?
>
> Thanks,
> Thomas
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20140220/d851525e/attachment.html 


More information about the IPython-dev mailing list