In my workflow, when testing/developing packages, It's an common situation to test internal packages functions that has been already loaded with the package, so they are in the MyPackage`Private context.

Today I know 2 options to test these functions.

1- Use full name like: Mypackage`Private`myFunction[x]

2- Comment Begin["`Private`"] and End[], and run the package again.

Number 1 is very verbose. Number 2 is dangerous (I sometimes forgot to uncomment it).

My question is:

There is another way to do that?

I tested the menu option: Notebook Default Context -> Other... But without success.

  • 1
    $\begingroup$ In such situations, I usually just add private context to $ContextPath like this: If[FreeQ[$ContextPath, #], PrependTo[$ContextPath, #]] &@"MyPackagePrivate". But I've just tried changing Notebook Default Context and it worked for me, so what precisely is not working in your case? $\endgroup$
    – jkuczm
    Commented Aug 25, 2015 at 22:05
  • 1
    $\begingroup$ You can make an input cell with the CellContext being MyPackage`Private` . Then you can use short names for private functions in that cell. You can automate creation of such cells with a palette or e.g. docked cell in your particular notebook. $\endgroup$ Commented Aug 26, 2015 at 20:17

1 Answer 1


You can run Begin["Mypackage`Private`"], then call myFunction[x] and any other private functions, followed by End[] in your test notebook or .mt file instead of commenting it in the package.

This way you don't need to modify your package, you only need to write out the context once and it will work the same way every time you run the code, regardless of notebook context options or the value of $ContextPath.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.