I'm just beginning with packages, so this is definitely a beginner's question. Suppose that I do this in a notebook:
BeginPackage["David`"]
$Context
$ContextPath
EndPackage[]
$Context
$ContextPath
The output is:
"David`" "David`" {"David`", "System`"} "Global`" {"David`", "WolframAlphaClient`", "IconizeLoader`", "HTTPHandlingLoader`", "StreamingLoader`", "InterpreterLoader`", "CloudObjectLoader`", "PacletManager`", "System`", "Global`"}
Note that "David`"
is the first on the $ContextPath
. Now, my question is, how to clear. I know one way is to simply quit the kernel with Quit
. I also did a little searching and tried this:
$ContextPath = DeleteCases[$ContextPath, "David`"]
The output is:
{"WolframAlphaClient`", "IconizeLoader`", "HTTPHandlingLoader`", "StreamingLoader`", "InterpreterLoader`", "CloudObjectLoader`", "PacletManager`", "System`", "Global`"}
So "David`"
has been removed from the $ContextPath
, so any functions or symbols created in the package (I did none) will not be found unless I put in their "long" name (such as David`total
). Am I correct?
But I am thinking this might not be enough, so I'd like to ask my colleagues "How do you clear a package?"