ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 20 Apr 2017 01:16:30 +0200Import class using mathematicahttps://ask.sagemath.org/question/37229/import-class-using-mathematica/I have a class a in a file a.sage using the interface to mathematica. I want to use this class in another class b.
One way I found was to run first "mv a.sage a.py", which generates a python file. But then I get the error: "NameError: global name 'mathematica' is not defined" because you cannot use mathematica in python as you can use it with sage.
Is there a way importing a self-written class (a.sage) using mathematica in another self-written class (b.sage)?Fri, 07 Apr 2017 19:34:45 +0200https://ask.sagemath.org/question/37229/import-class-using-mathematica/Comment by kcrisman for <p>I have a class a in a file a.sage using the interface to mathematica. I want to use this class in another class b.
One way I found was to run first "mv a.sage a.py", which generates a python file. But then I get the error: "NameError: global name 'mathematica' is not defined" because you cannot use mathematica in python as you can use it with sage.</p>
<p>Is there a way importing a self-written class (a.sage) using mathematica in another self-written class (b.sage)?</p>
https://ask.sagemath.org/question/37229/import-class-using-mathematica/?comment=37230#post-id-37230This would be a problem with anything similar, not just that particular interface. You may want to try `from sage.all import *` at the top of your `.py` file ...Fri, 07 Apr 2017 20:32:24 +0200https://ask.sagemath.org/question/37229/import-class-using-mathematica/?comment=37230#post-id-37230Answer by FrédéricC for <p>I have a class a in a file a.sage using the interface to mathematica. I want to use this class in another class b.
One way I found was to run first "mv a.sage a.py", which generates a python file. But then I get the error: "NameError: global name 'mathematica' is not defined" because you cannot use mathematica in python as you can use it with sage.</p>
<p>Is there a way importing a self-written class (a.sage) using mathematica in another self-written class (b.sage)?</p>
https://ask.sagemath.org/question/37229/import-class-using-mathematica/?answer=37234#post-id-37234In a .py file, you need to add some imports at the beginning. For example, if you need "mathematica", you can find what you should add using
sage: import_statements(mathematica)
from sage.interfaces.mathematica import mathematica
Sat, 08 Apr 2017 12:51:45 +0200https://ask.sagemath.org/question/37229/import-class-using-mathematica/?answer=37234#post-id-37234Comment by sageUser for <p>In a .py file, you need to add some imports at the beginning. For example, if you need "mathematica", you can find what you should add using</p>
<pre><code>sage: import_statements(mathematica)
from sage.interfaces.mathematica import mathematica
</code></pre>
https://ask.sagemath.org/question/37229/import-class-using-mathematica/?comment=37344#post-id-37344Thanks for the answer.Thu, 20 Apr 2017 01:16:30 +0200https://ask.sagemath.org/question/37229/import-class-using-mathematica/?comment=37344#post-id-37344