Ask Your Question
0

Import class using mathematica

asked 8 years ago

anonymous user

Anonymous

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

Preview: (hide)

Comments

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 ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

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
Preview: (hide)
link

Comments

Thanks for the answer.

sageUser gravatar imagesageUser ( 8 years ago )

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

Stats

Asked: 8 years ago

Seen: 1,107 times

Last updated: Apr 08 '17