[IPython-dev] IPython-dev Digest, Vol 121, Issue 28

Matthias Bussonnier bussonniermatthias at gmail.com
Sat Feb 22 04:20:18 EST 2014


Return/display an object that a repr text, html and JavaScript.

Text in console can be copy pasted, html in qtconsole will be clickable. Js in notebook will open a new tab (or a new window) depending on user preferences.

I find irritating that libs open a tab for me, wether I am in console or browser already. I would'nt implement the js part if it was me.

Envoyé de mon iPhone

> Le 21 févr. 2014 à 06:41, TARUN GABA <tarun.gaba7 at gmail.com> a écrit :
> 
> So the function I mention is supposed to open the browser with a specific url.
> Now if it is called from ipython notebook,  a browser is already open, so it simply opens up a new tab.
> If the method is called from command line interpreter or qtconsole instead of popping up a browser window (some people find it irritating), we can display a message that requests them to manually open browser and move to that url. What is the best approach for this?
> 
>> On 20 Feb 2014 23:35, <ipython-dev-request at scipy.org> wrote:
>> Send IPython-dev mailing list submissions to
>>         ipython-dev at scipy.org
>> 
>> To subscribe or unsubscribe via the World Wide Web, visit
>>         http://mail.scipy.org/mailman/listinfo/ipython-dev
>> or, via email, send a message with subject or body 'help' to
>>         ipython-dev-request at scipy.org
>> 
>> You can reach the person managing the list at
>>         ipython-dev-owner at scipy.org
>> 
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of IPython-dev digest..."
>> 
>> 
>> Today's Topics:
>> 
>>    1. Best way to detect IPython notebook (TARUN GABA)
>>    2. Re: Best way to detect IPython notebook (Matthias BUSSONNIER)
>> 
>> 
>> ----------------------------------------------------------------------
>> 
>> Message: 1
>> Date: Thu, 20 Feb 2014 22:15:33 +0530
>> From: TARUN GABA <tarun.gaba7 at gmail.com>
>> Subject: [IPython-dev] Best way to detect IPython notebook
>> To: ipython-dev at scipy.org
>> Message-ID:
>>         <CAHAono2LZ=DfeBRL-Y3k0J6c=UdE_pUX19ZTYAxLQMyZMi3AdA at mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>> 
>> Hi,
>> I have written a method, which behaves differently when called from IPython
>> notebook, and from interpreter/qtconsole respectively.
>> I need to detect whether the method is called from notebook or interpreter.
>> This was the code I was using till now.
>> 
>>     if get_ipython().config['KernelApp']['parent_appname'] ==
>> 'ipython-notebook':
>>         ##Do something
>> 
>> But I have came to know that this particular dict changes its format in
>> different IPython versions(I am not sure how many changes are there).
>> 
>> Is there any better method to achieve this?
>> Thanks in advance :)
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20140220/3ca3c0ab/attachment-0001.html
>> 
>> ------------------------------
>> 
>> Message: 2
>> Date: Thu, 20 Feb 2014 18:17:54 +0100
>> From: Matthias BUSSONNIER <bussonniermatthias at gmail.com>
>> Subject: Re: [IPython-dev] Best way to detect IPython notebook
>> To: IPython developers list <ipython-dev at scipy.org>
>> Message-ID: <6CC95483-B554-40C9-91AB-DB63FCDE0AA3 at gmail.com>
>> Content-Type: text/plain; charset=iso-8859-1
>> 
>> Hi,
>> 
>> Le 20 f?vr. 2014 ? 17:45, TARUN GABA a ?crit :
>> 
>> > Hi,
>> > I have written a method, which behaves differently when called from IPython notebook, and from interpreter/qtconsole respectively.
>> > I need to detect whether the method is called from notebook or interpreter.
>> > This was the code I was using till now.
>> >
>> >     if get_ipython().config['KernelApp']['parent_appname'] == 'ipython-notebook':
>> >         ##Do something
>> >
>> > But I have came to know that this particular dict changes its format in different IPython versions(I am not sure how many changes are there).
>> >
>> > Is there any better method to achieve this?
>> 
>> You should describe what you ment by "called from a notebook"
>> it is not clear enough to give a correct answer.
>> 
>> But if the question is the same as usual, and as stated in many discussion scattered
>> over the net and mailing list, there is no, and there will be no reliable way to detect which
>> frontend are requiring code execution, as there is no reason for a kernel to be connected
>> to only one frontend.
>> 
>> It is like a book writer asking "how can I make the eye color of my main character the same as my reader" ?
>> The question make no sense as two person can be reading the same page of the same book at the same time.
>> 
>> And as usual, if you describe what you are trying to archive instead of how,
>> you might get an answer that suit you.
>> 
>> 
>> Cheers,
>> --
>> Matthias
>> 
>> 
>> 
>> 
>> > Thanks in advance :)
>> > _______________________________________________
>> > IPython-dev mailing list
>> > IPython-dev at scipy.org
>> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>> 
>> 
>> 
>> ------------------------------
>> 
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>> 
>> 
>> End of IPython-dev Digest, Vol 121, Issue 28
>> ********************************************
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140222/be9285aa/attachment.html>


More information about the IPython-dev mailing list