2
$\begingroup$

I often digress to test some others’ code when working on my own problems. Usually, I have to check if there are conflict variables. Of course, it is not a wise way. By contrast, all the variables in Mathematica documentation center are parallel to the user’s opened notebook, even if they share the “same” name, that’s because they are in different context.

So, how to make the context of a new notebook different from the working one at the time they are opened?If this can be done, I won’t bother to restart Mathematica or clear all my variables to test them.

What’ more, is it possible to prevent the code from crushing the working kernel and front-end, even if there are serious bugs?

I guess that if the notebook can be opened in different kernels and different front-ends at the same time, all the irritating problem will be solved. But I don’t know how to do that.

$\endgroup$
2
  • $\begingroup$ The first answer tells you how to set it up to automatically do this. $\endgroup$
    – rcollyer
    Mar 25, 2013 at 12:53
  • $\begingroup$ @rcollyer Thanks a lot. I will check that. $\endgroup$
    – luyuwuli
    Mar 25, 2013 at 13:00

1 Answer 1

1
$\begingroup$

This command creates a new context every time it's run, (from second to second):-

SetOptions[EvaluationNotebook[],
 CellContext -> StringJoin["context$",
   ToString@IntegerPart@AbsoluteTime[]]]

$Context

context$3573205251`

$\endgroup$
1

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .