Begin["context`"]
resets the current context.
Begin
Begin["context`"]
resets the current context.
Examples
open all close allBasic Examples (1)
Define a function f in the MyContext` Context:
Begin["MyContext`"]f[x_] := x ^ 2 + 1End[]f will generally be hidden in the restored context:
??fThe definitions are all in MyContext`f :
??MyContext`fThe function can be called using its fully qualified name:
MyContext`f[a + b]Applications (1)
Make symbols used for package function definitions private, reducing the possibility for conflict:
BeginPackage["MyPackage`"]Any use of the symbol f in the package context ensures that f is created in that context:
f::usage = "f[x] gives x^2 + 1";When the context given to Begin starts with ` it extends from the current context:
Begin["`Private`"]f[x_] := x ^ 2 + 1;End[]EndPackage[]Since the symbol f is in the package context, the function works after EndPackage:
f[a + b]You can see that the other variable uses the private context:
??fProperties & Relations (3)
Begin["cont`"] sets $Context to "cont`":
$Context = "Global`";
Begin["Example`"]
$ContextEnd restores $Context to its value before the matching Begin:
End[];
$ContextUnlike BeginPackage, Begin does not modify $ContextPath:
$ContextPath = {"Global`", "System`"};
Begin["Example`"];
$ContextPathSimilarly, End does not modify it, either:
End[];
$ContextPathBegin does not alter the value of $ContextAliases:
$ContextAliases = <|"c`" -> "Context`"|>;
Begin["Example`"];
$ContextAliasesEnd restores $ContextAliases to its value before the matching Begin:
$ContextAliases["e`"] = "Experimental`";
End[];
$ContextAliasesSee Also
End BeginPackage EndPackage $ContextPath Context $ContextAliases CellContext
Function Repository: ContextDependencies
Tech Notes
Related Guides
Related Workflows
- Handle Shadowing of Symbol Names
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), Begin, Wolfram Language function, https://reference.wolfram.com/language/ref/Begin.html.
CMS
Wolfram Language. 1988. "Begin." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Begin.html.
APA
Wolfram Language. (1988). Begin. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Begin.html
BibTeX
@misc{reference.wolfram_2026_begin, author="Wolfram Research", title="{Begin}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Begin.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_begin, organization={Wolfram Research}, title={Begin}, year={1988}, url={https://reference.wolfram.com/language/ref/Begin.html}, note=[Accessed: 12-June-2026]}