I have some notebooks belonging to a project. I want them to share definitions with each other, but not with other notebooks.

Here is one approach that I thought would accomplish this: go to Evaluation > Kernel Configuration Options and add a new kernel, say mykernel. Then in each project notebook execute SetOptions[EvaluationNotebook[], Evaluator -> "mykernel"] to reset the kernel for that notebook.

To my surprise, symbol definitions appear to be shared across kernels. That is, if I have a non-project notebook running (Evaluation > Notebook's Kernel is local), it still sees all the defintions in the project notebooks.

I seem to have misunderstood what it means to assign a new kernel, which I though was equivalent to say "run in a separate process". I did not find the documentation helpful in understanding what is going on here. How can I get what I want?


I had closed and restarted Mma once to check on this behavior, and I still got the reported behavior. After Kuba's comments I did so again (as part of a more extensive experiment), and now I cannot replicate the reported behavior. I will edit this question again if I see it again (and would appreciate any confirming reports, especially if the cause is discovered).

Edit 2:

Motivation for use of separate kernel: privacy. (I don't want to worry about name clashes.)

Why not use contexts via Begin? As far as I can tell, Begin is almost completely unsafe for this purpose. Example:

ClearAll[f, x]
f[x_] := x^2 + 1
?? f

We find the definition apparently inside the block is in fact global (because the symbol f already existed at the global level).

  • $\begingroup$ I can't reproduce that behavior. What is Options[$FrontEnd, Evaluator]? $\endgroup$
    – Kuba
    Dec 11, 2015 at 16:38
  • $\begingroup$ You might want to check stackoverflow.com/questions/4896011/… $\endgroup$
    – Marvin
    Dec 11, 2015 at 16:54
  • $\begingroup$ @Kuba Interesting. Although the project notebooks show Evaluation > Notebook's Kernel is mykernel, I see that Options[$FrontEnd, Evaluator] produces {Evaluator -> "Local"}. How to reconcile? (Mma 10.2 on Win 7) $\endgroup$
    – Alan
    Dec 11, 2015 at 17:06
  • $\begingroup$ @Kuba So I think you are saying that my expectation was reasonable and what I am experiencing is surprising. $\endgroup$
    – Alan
    Dec 11, 2015 at 17:33
  • $\begingroup$ @Alan Indeed :) $\endgroup$
    – Kuba
    Dec 11, 2015 at 18:14

2 Answers 2


The described method with another Kernel works well for me. But here's another way, set this options for notebook you want to "shield":

 {CellProlog :> BeginPackage["c1`"], 
  CellEpilog :> (EndPackage[]; $ContextPath =.)}

or simply:

  CellContext -> "test`"
  • $\begingroup$ Maybe just drop c1 from $ContexPath instead of reseting it, your call. $\endgroup$
    – Kuba
    Dec 13, 2015 at 14:28

At the start of each notebook for a particular project, say ProjectNexus add the following Begin["ProjectNexus`"] . Make sure all the notebooks corresponding to the same project are in the same kernel.

  • $\begingroup$ As far as I know, all global symbols that reappear inside a Begin block are treated as global rather than context specific. See my edit. $\endgroup$
    – Alan
    Dec 13, 2015 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.