MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Two Notebooks Open at the Same Time

  • To: mathgroup at
  • Subject: [mg97545] Re: Two Notebooks Open at the Same Time
  • From: Bob F <deepyogurt at>
  • Date: Sat, 14 Mar 2009 18:18:08 -0500 (EST)
  • References: <gpg1eu$cjk$>

On Mar 14, 4:38 am, Gregory Lypny < at> wrote:
> Hello everyone,
> Is it possible to have more than one notebook active at a time, that  
> is, so that the variables of one do not conflict with variables in  
> another whose names are the same.  I notice that when I open a  
> Mathematica 7 notebook, under the Evaluation menu, the Default Kernel  
> is local, the Notebook's Kernel is local, and the Notebook's Default  
> Context is global.  Do I need to change anything?
> Regards,
>         Gregory

You will definitely have problems using the same variables in two
different open notebooks at the same time causing unexpected and
difficult to resolve problems. You should read the tutorial on
"Modularity and the naming of things", in the Documentation Center,
especially the sections on 'Contexts' and 'Modules and local
variables' (and others too).

There is only one "Global" context and by default all variables are in
this Global context (well there is also a System` context so guess
that is not quite correct), so that is why the same variable name in
two notebooks, open at the same time, will collide with each other.
Using Module[] or With[] functions to guarantee the scope of a
variable will help, but you can always create a variable with its own
"Context" by specifying the full name as


where xxxcontextnamexxx` is the "Context" and variablename is the
"short name" of the variable and there is a $ContextPath that tells
what order Contexts should be searched, that by default is System` and
then Global` (note the ` aka backquote is important) and the context
name can be any string I think.

You can use the Context[shortvariablename] function to tell you what
Mathematica thinks the context of the specified shortname of the
variable is to be certain it's what you think.



  • Prev by Date: Re: Maintaining a Mathematica bug list
  • Next by Date: Re: font size
  • Previous by thread: Re: Two Notebooks Open at the Same Time
  • Next by thread: Re: Two Notebooks Open at the Same Time