Ask Your Question
0

How can i use multiple sage worksheet in the cloud?

asked 2015-10-28 09:26:00 +0200

Geurt gravatar image

Hello,

Since a few days i'm using the cloud version of sagemath. I have made two different worksheet with defined function in them so far. Now i want to make a program which uses functions of both worksheets.

I really have no idea how i can use the function of a worksheet(.sagews file) in another worksheet. I've tried to convert the sagews file into a sage file and attach it but that didnt work. i'm getting the following error: "NameError: name 'Integer' is not defined".

Can someone tell me how to fix this?

thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-28 10:15:48 +0200

slelievre gravatar image

Create a text file with a .py or .sage extension, put in that file the code you want to reuse, and then load, runfile or attach that file in the Sage notebook worksheet (.sws) or SageMathCloud Sage worksheet (.sagews) or Jupyter notebook worksheet (.ipynb).

So for instance, in your SageMathCloud project, create a file mycode.sage, put in that file all the functions you want to reuse (you can copy-paste them from your initial .sagews worksheet), and then open a worksheet, say either playwithmycode.sagews or playwithmycode.ipynb (in that case select the Sage kernel from the Kernel > Change kernel menu item), and there you can load or runfile or attach mycode.sage and use all the functions that are defined there.

edit flag offensive delete link more

Comments

When using 'attach' i got some problems with my global variables ("NameError: name 'Integer' is not defined"). Instead i use 'load' now, this works fine. It all works now. Thanks!

Geurt gravatar imageGeurt ( 2015-10-28 14:56:36 +0200 )edit

I know that 'attach' was broken for quite a while, i.e. it would load once but not reload when the document was saved. I am not sure this is fixed.

slelievre gravatar imageslelievre ( 2015-10-29 10:29:57 +0200 )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

Stats

Asked: 2015-10-28 09:26:00 +0200

Seen: 321 times

Last updated: Oct 28 '15