This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

CellContext

CellContext
is an option for Cell which specifies the context to use for the evaluation of the contents of the cell.
  • The following settings can be given:
"context`"explicit context
Notebookunique to this notebook
CellGroupunique to this cell group
Cellunique to this cell
  • With CellContext->Cell, a unique default context is used for the current cell. This context is always different from the default contexts of all other cells, but stays the same for all evaluations done in the current cell.
  • With CellContext->CellGroup, a unique default context is used that is shared between all cells in the nearest enclosing group that includes the current cell and any output generated from it.
  • With CellContext->Notebook, a unique default context is used that is shared between all cells in the current notebook.
  • CellContext effectively allows sequences of evaluations to be isolated from each other within a single Mathematica session.
  • By changing the default context using CellContext, values of session variables such as In, Out, and $Line are effectively localized.
  • The values of $Context and $ContextPath are taken to be local to the context defined by CellContext. Any modifications made to them will affect all cells with the same default context.
  • Packages must typically be loaded separately in each default context generated by CellContext. The packages will not normally be visible across different default contexts.
  • CellContext is often set at the level of stylesheets or complete notebooks rather than individual cells.
Examples in this documentation use a unique CellContext for each example group:
Examples in this documentation use a unique CellContext for each example group:
In[1]:=
Click for copyable input
Out[1]=
New in 6