$ContextPath

$ContextPath
is a global variable that gives a list of contexts, after $Context, to search in trying to find a symbol that has been entered.

DetailsDetails

  • Each context is specified by a string of the form .
  • The elements of $ContextPath are tested in order to try to find a context containing a particular symbol.
  • $ContextPath is modified by BeginPackage and EndPackage.
  • $ContextPath is a rough analog for Mathematica symbols of the "search path" for files in many operating systems.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

The default contexts for looking up symbols:

In[1]:=
Click for copyable input
Out[1]=

If a symbol with a given name cannot be found in one of these contexts a new one is created:

In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=

It is created in the context given by $Context:

In[4]:=
Click for copyable input
Out[4]=

Turn off the message for new symbol creation:

In[5]:=
Click for copyable input
New in 1
New to Mathematica? Find your learning path »
Have a question? Ask support »