To expedite the work I do I have created a Mathematica Package that has all the functions I need to plot the data I need to analyze.

The problem is every now and then I will need to slightly modify one of the functions and will need to go and look for the .m package, copy the function onto the notebook, change the name, and work from there. I was wondering if there is any way that I could create a function inside the Package that would print the contents of the functions so I don't have to lose time searching. Something like PrintFunPac[Function1] that would return the definition of Function1.

Tried googling and didn't find anything. Thanks!


1 Answer 1


You can always enter

?? <packagename>`*

where <packagename> is the name of the package/context you want to inspect.

For example

?? Developer`*

contains many useful symbols.

For deeper hidden symbols, you can also try

?? <packagename>`*`*

Another helpful tool is hidden in the package "GeneralUtilities`". Run the following and be amazed:

  • 1
    $\begingroup$ Thank you so much!. The first thing you said ?? <packagename>* ` did return the definition of the functions but with the packagename`Private` in front of the variables' name, but your solution of Needs["GeneralUtilities`"]; PrintDefinitions[HoldPrint]; worked!! Thank you so much! $\endgroup$
    – M.O.
    Sep 12, 2018 at 18:47
  • $\begingroup$ You're welcome! $\endgroup$ Sep 12, 2018 at 18:51
  • $\begingroup$ @M.O. I think it is not clear what is the goal. Your question suggested you want to access the code and edit it but PrintDefinitions creates notebooks that are not ready to play with. Or is preview code the main goal? $\endgroup$
    – Kuba
    Sep 13, 2018 at 10:41
  • $\begingroup$ @Kuba, I thought I had been pretty straightforward but I guess not. The package I have created is done, but as the input data changes and the images are needed for different purposes, every now and then I need to change the functions of the package a bit. I was asking a way to get the definition of the function of my package, meaning the code, from mathematica instead of searching for the .m, copying the function, pasting it in the .nb, changing its name and then make the changes. Using Needs["GeneralUtilities"]; PrintDefinitions[HoldPrint];` as Henrik suggested did just that. $\endgroup$
    – M.O.
    Sep 13, 2018 at 13:02
  • 1
    $\begingroup$ @M.O. Huh! Yeah, that works. Great! So I also learned something here! =D $\endgroup$ Sep 13, 2018 at 13:18

Your Answer

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

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