0
$\begingroup$

I have a large MX file, which I need to Get before running my analysis. The following code puts the symbol in the Global context:

Begin["Ctx1`"];
Get["dat.mx"];
End[];

However, I would like dat to be imported into the Ctx1 context, so that I can refer to it with Ctx1'dat. Is there any way to force this behaviour?

$\endgroup$
3
  • 4
    $\begingroup$ The issue is the .mx file. It’s a binary representation that stores definitions directly, so it actually maintains the symbol context. If it were a .m file it’d be possible to do. Instead you’ll need to reassign the context after the fact—which is something you can read one of Leonid’s answers to learn how to do. $\endgroup$
    – b3m2a1
    Jul 10, 2018 at 22:46
  • $\begingroup$ Looks like an exact duplicate but let me know if you disagree with closing. $\endgroup$
    – Kuba
    Jul 11, 2018 at 6:23
  • $\begingroup$ No, I agree that it is a duplicate. This question can be closed. $\endgroup$ Jul 11, 2018 at 6:26

0

Browse other questions tagged or ask your own question.