Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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.

share|improve this question
    
The first answer tells you how to set it up to automatically do this. –  rcollyer Mar 25 '13 at 12:53
    
@rcollyer Thanks a lot. I will check that. –  luyuwuli Mar 25 '13 at 13:00
add comment

marked as duplicate by rcollyer, ruebenko, Yves Klett, István Zachar, whuber Mar 25 '13 at 13:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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`

share|improve this answer
    
Thanks. Well, just as rcollyer said, the problem is duplicate of [link]Is there a way to separate variables between multiple notebooks?(mathematica.stackexchange.com/questions/853/…) –  luyuwuli Mar 25 '13 at 13:21
add comment

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