Ask Your Question

Import class using mathematica

asked 2017-04-07 12:34:45 -0500

anonymous user


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", 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)?

edit retag flag offensive close merge delete


This 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 ...

kcrisman gravatar imagekcrisman ( 2017-04-07 13:32:24 -0500 )edit

1 answer

Sort by » oldest newest most voted

answered 2017-04-08 05:51:45 -0500

FrédéricC gravatar image

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

sage: import_statements(mathematica)
from sage.interfaces.mathematica import mathematica
edit flag offensive delete link more


Thanks for the answer.

sageUser gravatar imagesageUser ( 2017-04-19 18:16:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-04-07 12:34:45 -0500

Seen: 162 times

Last updated: Apr 08