Is it possible to import the contents of another (existing) notebook into the current namespace in the same way that I can with a package?
I know that it would be best to use a
.wl file, and I know that they can be created from
.nb, but I would like to avoid the hassle of having people doing these and I would like th ability to load directly a
For example, consider this scenario:
test = "This is a test"; x = f[2,4];
f[a_, b_] := a^b; Get[NotebookDirectory<>"data.nb"]; Print[test]; Print[x];
As that stand, evaluating
master.nb results in:
On the other hand, if I
data.wl file instead, I get the desired output:
This is a test
There is a solution that uses
NotebookEvaluate instead of
Get (see this answer) but it requires the context of each notebook to be global and thus will fail for anyone who has set each notebooks' context to be independent of each other.
So how can I load a
.nb file in such a way that it behaves like a package file?