Domanda

I usually have 5-10 different ipython notebooks running with associated consoles/kernels. It is hard for me to keep track of which console/kernel belongs to which notebook. For a while I put a comment with the notebook title at the top of each notebook and executed that comment in the kernel. That way I could type the '#' and then up arrow from console and it would show the comment. I think there is probably an easier way to keep track of my consoles.

The below code snippets show what is going on.

Suppose I am running an ipython notebook server, and I create a new notebook with a title called TestA.

Then suppose I run the following commands in the new notebook

%connect_info  #prints connection information
%qtconsole  

This opens up an ipython terminal console window (kernel might be the proper name) associated with the same notebook.

If I then type the following command in the ipython terminal console

%connect_info

I can determine which notebook is associated with which ipython consoles/kernels, but this requires a bit of work. Is there a command, magic, or macro that I can get the title (if present) of the currently running notebook?

I saw How do I get the current IPython Notebook name

Though the comments indicate this might not work, this solution appears to work on my setup but I wasn't sure if there is a better way to do this.

I decided to reask this question based on a Q&A on the SO meta site: https://meta.stackexchange.com/questions/147027/purposely-re-asking-duplicating-an-old-question

È stato utile?

Soluzione

Answer has not changed, by design the kernel does not know what is speaking to it. Like TV news presenter do not have a camera pointed on every person that listen to TV at night.

And as usual the question is what are you trying to accomplish, you might be trying to do something the hard way.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top