Skip to content

Commit d8ecaef

Browse files
committed
PyMathics fns and vars called w/o qualifying
Allow PyMathics functions and variabls to be called without qualifying the PytMathics context. With this, I thin last bit of work in to be done mathics is complete.
1 parent f422f9b commit d8ecaef

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mathics/builtin/assignment.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,4 +1710,17 @@ def apply(self, module, evaluation):
17101710
except PyMathicsLoadException as e:
17111711
evaluation.message(self.get_name(), 'notmathicslib', module)
17121712
return Symbol('$Failed')
1713+
else:
1714+
# Add PyMathics` to $ContextPath so that when user don't
1715+
# have to qualify PyMathics variables and functions,
1716+
# as the those in teh module just loaded.
1717+
1718+
# Following the example of $ContextPath in the WL
1719+
# reference manual where PackletManager appears first in
1720+
# the list, it seems to be preferable to add this PyMathics
1721+
# at the beginning.
1722+
context_path = evaluation.definitions.get_context_path()
1723+
if "PyMathics`" not in context_path:
1724+
context_path.insert(0, "PyMathics`")
1725+
evaluation.definitions.set_context_path(context_path)
17131726
return module

0 commit comments

Comments
 (0)