[IPython-dev] Jupyter and Other Kernels

Matthias Bussonnier bussonniermatthias at gmail.com
Sat Feb 21 13:26:06 EST 2015

Le 21 févr. 2015 à 09:04, John Omernik <john at omernik.com> a écrit :

> Since the Kernels that are developed for Jupyter look to be different
> projects, I am guessing that my question is ok to ask here, but
> understand if the response is "not an iPython or Jupyter" question.

The question looks fine here.

> I am playing with the iRKernel. https://github.com/takluyver/IRkernel
> and have a few questions on how kernels in general interact with
> Jupyter (not just IRKernel)
> 1. Magics: Based on what I am seeing in the iRKernel, Magics appear to
> be a "per Kernel" thing rather than a Jupyter thing. Is this correct?
> In the iRKernel %lsmagic gets me

Yes, they are per-kernel. 
If you write a python-base one, looks at Doug Blank Metakernel
that add some facilities to write magics. 

> Error in parse(text = x, srcfile = src): <text>:1:1: unexpected input
> 1: %lsmagic

As magic are per-kernel, the kernel is responsible to parse them. 
%lsmagic could be a perfect valid syntax in (perl | php | OCaml | ....) 
because it is **not** valid syntax in Python, wa can make them magic in 

> So anythoughts on how to implement magics in other kernels if this is
> not case? Am I missing something basic here?

Depends on your language. 
Julia decided they did not need magics. 
For example shell access in julia is with `;`
but it's a property of the language. 

Julia have strings macro, so that can do:
	(some matlab code)

Ruby have the same. 

Pick a syntax that is not valid R. and pre-parse to make it valid R. 
which is what IPtyhon does.  

> 2. So I have a some stuff running in iPython through my
> profile_default startup directory.  How do duplicate this so when an R
> Kernel starts up, I can have certain imports run all the time etc.  Is
> that a kernel specific thing as well?

That depends on your kernel. 
The kernel do whatever it likes. 
If it want to copy us and run the .r files in .ipython/startup, I suppose that would be fine. 

If we wan another common way of doing things, we can do a working group. 
But obviously, .py fies are not the right way to configure a R process. 


> Thanks1
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

More information about the IPython-dev mailing list